Giter Club home page Giter Club logo

cikit's People

Contributors

br0ken- avatar temoor-gilmutdinov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

cikit's Issues

Create "cikit-mssql" role

Why?

To do

Drop off Cygwin support and provide WSL operability on Windows hosts

  • Drop off Cygwin support (codebase).
  • Document the installation steps in WSL.
  • Adjust existing codebase for WSL.
  • Do manual tests.
  • Investigate why https://<PROJECT>.loc doesn't work in WSL (while port 80 is ok the 443 even not appears in server logs).
  • Provide possibility to handle web requests by more than single VM. For now, if you have more than one VM, web-pages of the first one will be opened visiting different domains.
  • Find a way to manage %SYSTEMROOT%\system32\drivers\etc\hosts automatically running Vagrant in WSL. (not possible)
  • Provide a way to open websites in Microsoft Edge.

Non-blocking todos

  • Replace the issues/52 by the master in WSL docs once PR will be merged.
  • Remove the link to the hashicorp/vagrant#9300 and the Resolution of known problem section from WSL docs when the problem will be gone.
  • Record a step-by-step video tutorial in a live mode once all tasks will be completed.

How to test this PR?

Run cikit self-update --version=issues/52 before creating projects via cikit init and provisioning VM via vagrant up. It's important.

Allow to forward custom ports

For instance, CIKit droplet could be just a host for MSSQL database which is accessible at the 1433 port. We should extend ports forwarding configuration and use NGINX TCP forwarding to accomplish this.

Add Pantheon integration

  • Add the cikit-pantheon-terminus role for installing the Terminus.
  • Introduce MySQL import strategies to allow gathering database snapshots via various ways.
  • Add documentation how to manage CIKit project which is hosted on Pantheon.

Create the "cikit-webserver" role

To do

  • Create the cikit-webserver role with the configuration for serving the virtual hosts.
  • Add the question to provisioning about which web server to use. Do not install Apache locally at all in case of Nginx.
  • Handle CI-specific cases when Nginx is chosen as a web-server for the project:
    • Do not pass the request to Apache (which will not be installed) and use fastcgi_pass to PHP-FPM.
    • Add PHP-FPM configuration to work in pair with Nginx.
    • Do not allow changing a web server that was chosen during provisioning the droplet.
    • Provide kinda VirtualDocumentRoot to be able opening project's builds on subdomains.
  • Allow building a VM from scratch when one of the available web servers is chosen by default:
    • apache2
    • nginx
  • Allow overwriting virtual host configuration within the project:
    • apache2
    • nginx
  • Update the documentation.
  • Create the changelog that describes manual actions that have to be taken.
  • Increase CIKit version and add migration information.
  • Add tests?

Rewrite "cikit" utility on Python

cikit requires Ansible to be installed on a controlling system which means that Python is available. Let's use it because Bash logic starts becoming complex.

[Jenkins] Handle actions from commit messages

Synopsis

git add composer.json composer.lock
git commit -m '[composer update][skip tests] Update Composer dependencies'

Created in a such way commit must to be recognized by Jenkins which should extract the composer update and skip tests actions from the message and pass them to Ansible playbook as an array. Further logic to handle the actions must be built in there.

An error message occurs after selecting preferable packages

There is an issue with the latest version of CIKit when trying to provision a local virtual machine. Steps to reproduce:

  1. Install CIKit:
    curl -LSs https://raw.githubusercontent.com/BR0kEN-/cikit/master/install.sh | bash
  2. Initialize a project:
    cikit init --project=dummyproject
  3. Go to the project's directory and run:
    vagrant up --provision

After these steps a corresponding VirtualBox VM will be turned on and a provision script will ask which versions of packets to install. Right after this, Python will throw an error and provisioning will stop:

==> default: Running provisioner: cikit...
Which version of PHP you'd want to install? (5.6/7.0/7.1) [5.6]:
Which version of Node.js you'd want to install? (4/5/6/7) [6]:
Which version of Ruby you'd want to install? (2.1.10/2.2.6/2.3.3/2.4.0) [2.4.0]:
Which version of Solr you'd want to install? (5.5.5/6.6.2/no) [6.6.2]:
Do you want to install Microsoft SQL Server? (yes/no) [no]:
Traceback (most recent call last):
File "/usr/local/share/cikit/lib/cikit", line 20, in <module>
import __init__
File "/usr/local/share/cikit/lib/__init__.py", line 107, in <module>
'import yaml, json\nprint json.dumps(yaml.load(open(\'%s\')))' % ENV_CONFIG,
File "/usr/local/share/cikit/lib/functions.py", line 28, in call
return Popen(nargs, stdout=PIPE, **kwargs).stdout.read().rstrip()
File "/usr/lib/python2.7/subprocess.py", line 711, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
CIKit provisioner responded with a non-zero exit status.

The host environment:

Ubuntu 16.04.3 LTS (Linux 4.4.0-109-generic)
VirtualBox 5.1.32
Vagrant 1.9.5
Python 2.7.12
Ansible 2.4.2.0

As we've figured out, there is a correct environment.yml file in the project's directory and the condition os.path.isfile(ENV_CONFIG) is satisfied.

The issue doesn't affect the provisioning process of a remote CI server.

Form the "inventory" dynamically

We have a well-done structure of the PROJECT_DIR/.cikit/inventory so we can easily form it automatically. All unique data we need - credentials to the droplets host.

Automatically compute the mirror URL for downloading Solr

Download from Ukrainian mirror while located in Ukraine:

time wget http://apache.volia.net/lucene/solr/6.6.2/solr-6.6.2.tgz
--2017-11-22 17:34:47--  http://apache.volia.net/lucene/solr/6.6.2/solr-6.6.2.tgz
Resolving apache.volia.net... 82.144.192.7, 82.144.192.7
Connecting to apache.volia.net|82.144.192.7|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 147343211 (141M) [application/x-gzip]
Saving to: ‘solr-6.6.2.tgz.1’

solr-6.6.2.tgz.1                                   100%[================================================================================================================>] 140.52M  8.62MB/s    in 15s

2017-11-22 17:35:02 (9.40 MB/s) - ‘solr-6.6.2.tgz.1’ saved [147343211/147343211]


real	0m15.214s
user	0m0.112s
sys	0m0.974s

Download from the original location while located in Ukraine:

time wget http://archive.apache.org/dist/lucene/solr/6.6.2/solr-6.6.2.tgz
--2017-11-22 17:34:09--  http://archive.apache.org/dist/lucene/solr/6.6.2/solr-6.6.2.tgz
Resolving archive.apache.org... 163.172.17.199
Connecting to archive.apache.org|163.172.17.199|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 147343211 (141M) [application/x-gzip]
Saving to: ‘solr-6.6.2.tgz’

solr-6.6.2.tgz                                      62%[=====================================================================>                                           ]  87.60M  53.1KB/s    eta 22m 5s

Result: 100%/15 sec. vs 62%/22 min. I think comments are unnecessary.

To do

Getting 403 on vagrant up when installing packages with pip

I'm trying to setup cikit project, but when I run vagrant up I get the following error:

TASK [Install EasyInstall and PIP] *********************************************
failed: [default] (item={u'tool': u'easy_install', u'script': u'curl -s https://raw.githubusercontent.com/ActiveState/ez_setup/v0.9/ez_setup.py | python'}) => {"changed": true, "cmd": "[ $(which easy_install) ] || curl -s https://raw.githubusercontent.com/ActiveState/ez_setup/v0.9/ez_setup.py | python", "delta": "0:00:00.760523", "end": "2017-11-01 05:09:10.169754", "failed": true, "item": {"script": "curl -s https://raw.githubusercontent.com/ActiveState/ez_setup/v0.9/ez_setup.py | python", "tool": "easy_install"}, "msg": "non-zero return code", "rc": 1, "start": "2017-11-01 05:09:09.409231", "stderr": "Downloading http://pypi.python.org/packages/source/d/distribute/distribute-0.6.14.tar.gz\nTraceback (most recent call last):\n  File \"<stdin>\", line 485, in <module>\n  File \"<stdin>\", line 480, in main\n  File \"<stdin>\", line 193, in download_setuptools\n  File \"/usr/lib/python2.7/urllib2.py\", line 154, in urlopen\n    return opener.open(url, data, timeout)\n  File \"/usr/lib/python2.7/urllib2.py\", line 435, in open\n    response = meth(req, response)\n  File \"/usr/lib/python2.7/urllib2.py\", line 548, in http_response\n    'http', request, response, code, msg, hdrs)\n  File \"/usr/lib/python2.7/urllib2.py\", line 473, in error\n    return self._call_chain(*args)\n  File \"/usr/lib/python2.7/urllib2.py\", line 407, in _call_chain\n    result = func(*args)\n  File \"/usr/lib/python2.7/urllib2.py\", line 556, in http_error_default\n    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)\nurllib2.HTTPError: HTTP Error 403: SSL is required", "stderr_lines": ["Downloading http://pypi.python.org/packages/source/d/distribute/distribute-0.6.14.tar.gz", "Traceback (most recent call last):", "  File \"<stdin>\", line 485, in <module>", "  File \"<stdin>\", line 480, in main", "  File \"<stdin>\", line 193, in download_setuptools", "  File \"/usr/lib/python2.7/urllib2.py\", line 154, in urlopen", "    return opener.open(url, data, timeout)", "  File \"/usr/lib/python2.7/urllib2.py\", line 435, in open", "    response = meth(req, response)", "  File \"/usr/lib/python2.7/urllib2.py\", line 548, in http_response", "    'http', request, response, code, msg, hdrs)", "  File \"/usr/lib/python2.7/urllib2.py\", line 473, in error", "    return self._call_chain(*args)", "  File \"/usr/lib/python2.7/urllib2.py\", line 407, in _call_chain", "    result = func(*args)", "  File \"/usr/lib/python2.7/urllib2.py\", line 556, in http_error_default", "    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)", "urllib2.HTTPError: HTTP Error 403: SSL is required"], "stdout": "", "stdout_lines": []}
failed: [default] (item={u'tool': u'pip', u'script': u'easy_install pip'}) => {"changed": true, "cmd": "[ $(which pip) ] || easy_install pip", "delta": "0:00:00.003229", "end": "2017-11-01 05:09:10.794231", "failed": true, "item": {"script": "easy_install pip", "tool": "pip"}, "msg": "non-zero return code", "rc": 127, "start": "2017-11-01 05:09:10.791002", "stderr": "/bin/bash: easy_install: command not found", "stderr_lines": ["/bin/bash: easy_install: command not found"], "stdout": "", "stdout_lines": []}

PLAY RECAP *********************************************************************
default                    : ok=11   changed=2    unreachable=0    failed=1

Here is a link to Stack overflow: https://stackoverflow.com/questions/46967488/getting-error-403-while-installing-package-with-pip

Make environment configuration shippable

Currently, during provisioning the VM, all answers on questions are storing in file inside of .vagrant directory, which is completely personal for every particular user.

The idea is to have this YAML file available within project directory with ability to commit it to VCS to automatically inform every team member about environment configuration changing.

Allow having as many as CIKits Selenium grids

Currently it's allowed to have only one Selenium grid, so you need to halt other projects for tests run. Also, the selenium service must be reworked since Ubuntu 16.04 has the systemd which does not allow to pass arguments to service.

Do not require ".hosts.json" to be presented

Those, who haven't added a host using cikit host/add might not have the .hosts.json that will make an entire inventory to be not formed at all. This is a follow-up for the #87.

To do

  • Add necessary fixes.
  • Add tests.

Copy full project to the "/var/www" after build

Now we're copying the docroot only to the /var/www/BUILD_ID and this might bring some implications due to missing files. For instance, Composer packages or Drupal 8 configs, for now, forced to be lying in the docroot instead of the directory above it.

Changes

  • https://ci_server.com/project_build_1 to be changed by https://project_build_1.ci_server.com. This is a mandatory change allowing to use the VirtualDocumentRoot on CI server.
  • Make http://project_build_1.localhost:8080 accessible within the local network for running tests (or for anything else without basic HTTP auth).

New features

  • DNS nameservers configuration.

Introduced flaws

  • HTTP auth will be required for every subdomain (build).

Update Ubuntu to 16.04

Blockers

This PR resolves the following automatically

Markup

  • bold - added
  • strikethrough - removed

Get rid of the requirement to define the matrix's host on every machine

Synopsis

At the moment, to use SQL workflow via SSH, every project member must have defined the parent host (SSH credentials to a matrix).

Structure of CIKit components

cikit_components_structure

In order to be able to connect to CI server from local machine or VM, you must know the hostname, port, user and have a private SSH key. If the credentials for a droplet is shared then the port number can be automatically obtained from the droplet's name (e.g. cikitNN where NN is a serial number of a port), the user will be root by default, a key will be stored in a directory and only the hostname for a matrix remains unknown. To overcome this we can share the hostnames in projects as well.

Problem

Every teammate must do something like cikit host/add --alias=matrixName --domain=example.com --ssh-key=/path/to/private.key before the entire scheme will start working. This is a security problem since as less as possible users must have the credentials to Matrix.

Remove the "ANSIBLE_ARGS" environment variable since it dangerous for "cikit" runner

  • Fix deprecation warnings running cikit init --project=tolik.
  • Convert the cikit provision --list-tags to CIKIT_LIST_TAGS=true cikit provision to not mix custom playbook options with the options for ansible-playbook.
  • Convert the cikit provision --tags=tag1,tag2,tagN to CIKIT_TAGS="tag1,tag2,tagN" cikit provision to not mix custom playbook options with the options for ansible-playbook.
  • Completelly remove the ANSIBLE_ARGS environment variable because we're forming a set of options for the ansible-playbook by some logic and this variable may contain a raw set of arguments which will conflict with necessary ones.
  • Leave only the --limit option for the cikit utility which is a passthrough to ansible-playbook.
  • Introduce the CIKIT_VERBOSE environment variable allowing to add -vv to the ansible-playbok when defined.
  • Remove CIKIT_VERBOSE and use ANSIBLE_VERBOSITY (https://github.com/ansible/ansible/blob/devel/lib/ansible/config/base.yml#L1126).

Add extra mapping to "hosts" based on the "web_server_vhosts" variable

As a follow-up for the https://github.com/BR0kEN-/cikit/issues/49 we can introduce a new nice improvement.

The web-server.yml has the list of virtual hosts, e.g.:

web_server_vhosts:
  # Serve "project.loc" in the "docroot".
  - name: "{{ project }}"
    root: "docroot"
  - name: "subdomain.{{ project }}"
    root: "subdomain-docroot"

The configuration above will produce two virtual hosts (for any chosen web server) for serving project.loc from /var/www/docroot and subdomain.project.loc from /var/www/subdomain-docroot.

The problem here is that only project.loc will be added to /etc/hosts by the vagrant-hostsupdater plugin by reading a value from the config.vm.hostname in the Vagrantfile. The subdomain.project.loc with a corresponding IP should be added manually and it's a flaw due to automatic IP resolution: when IP gets updated the entry won't remain working.

To do

  • Disallow Ansible logic and variable usage within the web_server_vhosts variable. This will allow using plain-text values in config.hostsupdater.aliases at Vagrantfile for adding necessary records to /etc/hosts.

    A new look of the file:

    ---
    # WARNING! Do not use any variables or logic within the "web_server_vhosts"
    # variable. It must be plain as used as a source for creating aliases for
    # VM's VPN by just reading the YAML structure of this file without any
    # Ansbile/Jinja2 evaluation.
    #
    # The "{{ project }}.loc" will be served from the "/var/www/docroot" without
    # any configuration here.
    #
    # Serve "subdomain.{{ project }}.loc" from the "/var/www/subdomain".
    # - name: subdomain
    web_server_vhosts: []
  • Read the web_server_vhosts from the web-server.yml of a project and form an array of aliases for the vagrant-hostsupdater Vagrant plugin.

  • Adjust logic of creating virtual hosts (nginx and apache2).

  • Update the documentation.

  • Add the changelog record.

Make CIKit a system-wide package

Do not ship provisioning, cikit utility, Vagratfile, provisioners and other important stuff which becomes outdated when CIKit gets an update.

To do

  • Make an installer (via git) to /usr/local/share/cikit and automatic creation of symlink to cikit utility.
  • Update the Vagrant box with a Vagrantfile which will have an include of /usr/local/share/cikit/vagrant/Vagrantfile.
  • Add ability to include Ansible roles into provision process.
  • Make cikit self-update to grab latest updates of CIKit.
  • Add installation of the cikit package to CI server.
  • Replace cikit repository by cikit init and initialize a project in CWD.

Divide "matrix/matrix" to "matrix/provision" and "matrix/droplet"

Why?

At the moment the host for droplets can be created by cikit matrix/matrix --limit=HOST. The command is simple and explicit, unlike the command to list/add/start/stop/restart/delete droplet(s) - CIKIT_TAGS="vm" cikit matrix/matrix --limit=HOST --droplet-[list|add|start|stop|restart|delete].

Despite on confusing matrix/matrix in both of cases, you can easily forget to add CIKIT_TAGS="vm" and run host provisioning once again. This takes much more time.

To do

  • Use matrix/provision --limit=HOST to provision the host.
  • Use matrix/droplet --limit=HOST --droplet-<ACTION> to manage the droplets.
  • Add autocomplete functionality for all playbooks from matrix/* directory to cikit utility.
  • Avoid code copy-paste.

"is_reinstall_mode" is undefined doing "cikit reinstall"

vagrant@test:~$ cikit reinstall

PLAY [localhost] *******************************************************************************************************************************************************************************************

TASK [Gathering Facts] *************************************************************************************************************************************************************************************
ok: [localhost]

TASK [Set path to directory, where project accessible from web] ********************************************************************************************************************************************
ok: [localhost]

TASK [Set path to directory, where project codebase located] ***********************************************************************************************************************************************
ok: [localhost]

TASK [Set path to reports directory and URL by which they will be accessible] ******************************************************************************************************************************
ok: [localhost]

TASK [Ensure that project directory has correct permissions] ***********************************************************************************************************************************************
ok: [localhost] => (item=/var/www/docroot)
ok: [localhost] => (item=/var/www/docroot/reports)
changed: [localhost] => (item=/var/www/docroot/sites/default)

TASK [Initialize an empty build report] ********************************************************************************************************************************************************************
ok: [localhost]

TASK [Check installation of Composer packages] *************************************************************************************************************************************************************
ok: [localhost]

TASK [Check for composer.json existence] *******************************************************************************************************************************************************************
ok: [localhost]

TASK [Install Composer packages] ***************************************************************************************************************************************************************************

TASK [Check existence of installation mode] ****************************************************************************************************************************************************************
ok: [localhost]

TASK [Check existence of environment configuration] ********************************************************************************************************************************************************
ok: [localhost]

TASK [Obtain home directory of a user, who triggered this script] ******************************************************************************************************************************************
changed: [localhost]

TASK [Set the user's home directory] ***********************************************************************************************************************************************************************
ok: [localhost]

TASK [Ensure directory for backup data exists] *************************************************************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "gid": 80, "group": "80", "mode": "0777", "msg": "chown failed: [Errno 1] Operation not permitted: '/var/www/backup'", "owner": "501", "path": "/var/www/backup", "size": 68, "state": "directory", "uid": 501}
...ignoring

TASK [Seek for SSH keys] ***********************************************************************************************************************************************************************************
ok: [localhost]

TASK [Copy SSH keys] ***************************************************************************************************************************************************************************************

TASK [include_vars] ****************************************************************************************************************************************************************************************
ok: [localhost]

TASK [Compute actions to run] ******************************************************************************************************************************************************************************
ok: [localhost] => (item=composer)
ok: [localhost] => (item=npm)

TASK [include_tasks] ***************************************************************************************************************************************************************************************
included: /var/www/scripts/tasks/reinstall/actions/packages-install.yml for localhost

TASK [include_tasks] ***************************************************************************************************************************************************************************************
included: /var/www/scripts/tasks/reinstall/actions/cache-get.yml for localhost

TASK [Check for Composer packages in cache] ****************************************************************************************************************************************************************
ok: [localhost]

TASK [Check for Composer packages at place] ****************************************************************************************************************************************************************
ok: [localhost]

TASK [Check whether Composer packages should be reinstalled] ***********************************************************************************************************************************************
ok: [localhost]

TASK [Copy Composer packages from cache] *******************************************************************************************************************************************************************

TASK [Check for /var/www/docroot/composer.json] ************************************************************************************************************************************************************
ok: [localhost]

TASK [Install Composer packages] ***************************************************************************************************************************************************************************

TASK [include_tasks] ***************************************************************************************************************************************************************************************

TASK [include_tasks] ***************************************************************************************************************************************************************************************
fatal: [localhost]: FAILED! => {"failed": true, "reason": "'is_reinstall_mode' is undefined"}

PLAY RECAP *************************************************************************************************************************************************************************************************
localhost                  : ok=22   changed=2    unreachable=0    failed=1
  • If we put - debug: var=is_reinstall_mode right before the include_tasks the correct value of the variable will be shown.
  • If we remove the condition and will do just - include_tasks: "tasks/reinstall/modes/full.yml" the new error will appear:
fatal: [localhost]: FAILED! => {"failed": true, "msg": "The task includes an option with an undefined variable. The error was: 'state' is undefined\n\nThe error appears to have been in '/var/www/scripts/tasks/database/database.yml': line 2, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n---\n- name: \"{{ name | default('command') }}\"\n  ^ here\nWe could be wrong, but this one looks like it might be an issue with\nmissing quotes.  Always quote template expression brackets when they\nstart a value. For instance:\n\n    with_items:\n      - {{ foo }}\n\nShould be written as:\n\n    with_items:\n      - \"{{ foo }}\"\n\nexception type: <class 'ansible.errors.AnsibleUndefinedVariable'>\nexception: 'state' is undefined"}

Update the "ansible-role-nginx" to get rid of deprecation warnings

For now we're living looking at the next warning during provisioning:

[DEPRECATION WARNING]: The use of 'include' for tasks has been deprecated. Use
'import_tasks' for static inclusions or 'include_tasks' for dynamic inclusions.
 This feature will be removed in a future release. Deprecation warnings can be
disabled by setting deprecation_warnings=False in ansible.cfg.

But https://github.com/jdauphant/ansible-role-nginx has been updated and now supports Ansible 2.4.x. So let's update the package.

Improve API for integrating new CMF/CMS

To do

  • Form the cmfs variable dynamically: add main.yml within cmf/drupal and cmf/wordpress and scan for those files.
  • Add tests.
  • Update the documentation.
  • Add the changelog record.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.