From e5e734cd26146212a8557444dd179f135b71fe40 Mon Sep 17 00:00:00 2001 From: Nikita Strelkov Date: Mon, 3 Oct 2016 11:42:26 +0500 Subject: [PATCH 01/10] Fix php 7.0 installation --- ansible/roles/php/tasks/main.yml | 12 +++++++++++- ansible/roles/php/tasks/php-cli.yml | 16 ++++++++-------- ansible/vars/all.yml | 4 +++- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/ansible/roles/php/tasks/main.yml b/ansible/roles/php/tasks/main.yml index b82c2f6..299b98e 100755 --- a/ansible/roles/php/tasks/main.yml +++ b/ansible/roles/php/tasks/main.yml @@ -1,4 +1,8 @@ --- +- name: Update apt + become: yes + apt: update_cache=yes autoremove=yes + - name: Add ppa Repository sudo: yes apt_repository: repo=ppa:ondrej/{{ php.ppa }} @@ -14,7 +18,13 @@ - name: Install PHP Packages sudo: yes apt: pkg={{ item }} state=latest - with_items: php.packages + with_items: '{{ php.packages }}' + when: php.packages is defined + +- name: Install PHP PECL Packages + become: yes + apt: pkg={{ item }} state=latest force=yes + with_items: '{{ php.pecl_packages }}' when: php.packages is defined - include: configure.yml diff --git a/ansible/roles/php/tasks/php-cli.yml b/ansible/roles/php/tasks/php-cli.yml index e1cfffa..35b1daf 100755 --- a/ansible/roles/php/tasks/php-cli.yml +++ b/ansible/roles/php/tasks/php-cli.yml @@ -1,10 +1,10 @@ --- -- name: ensure timezone is set in cli php.ini - lineinfile: dest=/etc/php5/cli/php.ini - regexp='date.timezone =' - line='date.timezone = {{ server.timezone }}' - - name: enabling opcache cli - lineinfile: dest=/etc/php5/cli/php.ini - regexp=';opcache.enable_cli=0' - line='opcache.enable_cli=1' + lineinfile: dest=/etc/php/7.0/cli/php.ini + regexp=';?opcache.enable=\d' + line='opcache.enable=1' + +- name: ensure timezone is set in cli php.ini + lineinfile: dest=/etc/php/7.0/cli/php.ini + regexp='date.timezone =' + line='date.timezone = {{ server.timezone }}' \ No newline at end of file diff --git a/ansible/vars/all.yml b/ansible/vars/all.yml index fe15f1e..d85e094 100755 --- a/ansible/vars/all.yml +++ b/ansible/vars/all.yml @@ -10,6 +10,8 @@ vagrant_local: php: install: '1' ppa: php - packages: [php7.0-cli, php7.0-intl, php7.0-mcrypt, php7.0-mysql, php7.0-curl, php7.0-json, php7.0-xml] + packages: [php7.0-cli, php7.0-intl, php7.0-mcrypt, php7.0-mysql, php7.0-curl, php7.0-json, php7.0-xml, php7.0-mbstring] + pecl_packages: [php-zip] + xdebug: install: '1' From e8f15607126b8229ada53d99be966060af127328 Mon Sep 17 00:00:00 2001 From: Nikita Strelkov Date: Mon, 3 Oct 2016 11:42:52 +0500 Subject: [PATCH 02/10] Add global composer installation and running 'composer install' --- ansible/playbook.yml | 1 + ansible/roles/composer/tasks/main.yml | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 ansible/roles/composer/tasks/main.yml diff --git a/ansible/playbook.yml b/ansible/playbook.yml index 33e3fda..055d6f7 100755 --- a/ansible/playbook.yml +++ b/ansible/playbook.yml @@ -9,3 +9,4 @@ - php - xdebug - app + - composer diff --git a/ansible/roles/composer/tasks/main.yml b/ansible/roles/composer/tasks/main.yml new file mode 100644 index 0000000..4d362c3 --- /dev/null +++ b/ansible/roles/composer/tasks/main.yml @@ -0,0 +1,5 @@ +- name: Install Composer + shell: curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer creates=/usr/local/bin/composer + +- name: Install packages + shell: cd /vagrant && composer install --optimize-autoloader From fe0faca89dde62b0c2aa6120ecd67e9c2a796a48 Mon Sep 17 00:00:00 2001 From: Nikita Strelkov Date: Mon, 3 Oct 2016 11:43:24 +0500 Subject: [PATCH 03/10] Update packages --- composer.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.lock b/composer.lock index 93cae18..da95186 100644 --- a/composer.lock +++ b/composer.lock @@ -211,16 +211,16 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "3.1.0", + "version": "3.1.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "9270140b940ff02e58ec577c237274e92cd40cdd" + "reference": "8331b5efe816ae05461b7ca1e721c01b46bafb3e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/9270140b940ff02e58ec577c237274e92cd40cdd", - "reference": "9270140b940ff02e58ec577c237274e92cd40cdd", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/8331b5efe816ae05461b7ca1e721c01b46bafb3e", + "reference": "8331b5efe816ae05461b7ca1e721c01b46bafb3e", "shasum": "" }, "require": { @@ -252,7 +252,7 @@ } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2016-06-10 09:48:41" + "time": "2016-09-30 07:12:33" }, { "name": "phpdocumentor/type-resolver", From a7f40a2083e6790c3f3f4dcbc3fefe239a9ab338 Mon Sep 17 00:00:00 2001 From: Nikita Strelkov Date: Tue, 4 Oct 2016 13:35:00 +0500 Subject: [PATCH 04/10] Fix pecl_packages installation condition --- ansible/roles/php/tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ansible/roles/php/tasks/main.yml b/ansible/roles/php/tasks/main.yml index 299b98e..80fe97d 100755 --- a/ansible/roles/php/tasks/main.yml +++ b/ansible/roles/php/tasks/main.yml @@ -25,6 +25,6 @@ become: yes apt: pkg={{ item }} state=latest force=yes with_items: '{{ php.pecl_packages }}' - when: php.packages is defined + when: php.pecl_packages is defined - include: configure.yml From fda3dd4584ff8b31de36cf0efa3f5820d23d0de0 Mon Sep 17 00:00:00 2001 From: Nikita Strelkov Date: Wed, 5 Oct 2016 20:14:31 +0500 Subject: [PATCH 05/10] Add installation of GIT and make list of php packages more readable --- ansible/vars/all.yml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/ansible/vars/all.yml b/ansible/vars/all.yml index d85e094..1d0e7d2 100755 --- a/ansible/vars/all.yml +++ b/ansible/vars/all.yml @@ -1,7 +1,7 @@ --- server: install: '1' - packages: [vim, htop, iotop, bwm-ng] + packages: [vim, htop, iotop, bwm-ng, git] timezone: UTC locale: en_US.UTF-8 vagrant_local: @@ -10,8 +10,19 @@ vagrant_local: php: install: '1' ppa: php - packages: [php7.0-cli, php7.0-intl, php7.0-mcrypt, php7.0-mysql, php7.0-curl, php7.0-json, php7.0-xml, php7.0-mbstring] + packages: + - php7.0-cli + - php7.0-intl + - php7.0-mcrypt + - php7.0-mysql + - php7.0-curl + - php7.0-json + - php7.0-xml + - php7.0-mbstring pecl_packages: [php-zip] xdebug: install: '1' + +composer: + timeout: '2000' \ No newline at end of file From cfff327fb21864ab1249c2f4ea3614c14b802ff5 Mon Sep 17 00:00:00 2001 From: Nikita Strelkov Date: Wed, 5 Oct 2016 21:25:16 +0500 Subject: [PATCH 06/10] Remove `sudo` and `become` from roles and use one `become` in playbook --- ansible/playbook.yml | 2 +- ansible/roles/app/tasks/main.yml | 1 - ansible/roles/php/tasks/main.yml | 15 ++------------- ansible/roles/server/tasks/main.yml | 12 +++--------- ansible/roles/xdebug/tasks/main.yml | 1 - 5 files changed, 6 insertions(+), 25 deletions(-) diff --git a/ansible/playbook.yml b/ansible/playbook.yml index 055d6f7..150b16a 100755 --- a/ansible/playbook.yml +++ b/ansible/playbook.yml @@ -1,6 +1,6 @@ --- - hosts: all - sudo: true + become: yes vars_files: - vars/all.yml roles: diff --git a/ansible/roles/app/tasks/main.yml b/ansible/roles/app/tasks/main.yml index c330e48..59e8b64 100755 --- a/ansible/roles/app/tasks/main.yml +++ b/ansible/roles/app/tasks/main.yml @@ -1,5 +1,4 @@ --- # application tasks to be customized and to run after the main provision - name: update file db - sudo: yes shell: updatedb diff --git a/ansible/roles/php/tasks/main.yml b/ansible/roles/php/tasks/main.yml index 80fe97d..03fede2 100755 --- a/ansible/roles/php/tasks/main.yml +++ b/ansible/roles/php/tasks/main.yml @@ -1,30 +1,19 @@ --- - name: Update apt - become: yes apt: update_cache=yes autoremove=yes - name: Add ppa Repository - sudo: yes apt_repository: repo=ppa:ondrej/{{ php.ppa }} - name: Update apt - sudo: yes apt: update_cache=yes - name: Install php7 - sudo: yes apt: pkg=php7.0 state=latest - name: Install PHP Packages - sudo: yes - apt: pkg={{ item }} state=latest - with_items: '{{ php.packages }}' + apt: pkg="{{ item }}" state=latest + with_items: "{{ php.packages }}" when: php.packages is defined -- name: Install PHP PECL Packages - become: yes - apt: pkg={{ item }} state=latest force=yes - with_items: '{{ php.pecl_packages }}' - when: php.pecl_packages is defined - - include: configure.yml diff --git a/ansible/roles/server/tasks/main.yml b/ansible/roles/server/tasks/main.yml index f1ffc08..78efb9f 100755 --- a/ansible/roles/server/tasks/main.yml +++ b/ansible/roles/server/tasks/main.yml @@ -1,31 +1,25 @@ --- - name: Update apt - sudo: yes apt: update_cache=yes - name: Install System Packages - sudo: yes - apt: pkg={{ item }} state=latest + apt: pkg="{{ item }}" state=latest with_items: - curl - wget - python-software-properties - name: Install Extra Packages - sudo: yes - apt: pkg={{ item }} state=latest - with_items: server.packages + apt: pkg="{{ item }}" state=latest + with_items: "{{ server.packages }}" when: server.packages is defined - name: Configure the timezone - sudo: yes template: src=timezone.tpl dest=/etc/timezone - name: More Configure the timezone - sudo: yes file: src=/usr/share/zoneinfo/{{server.timezone}} dest=/etc/localtime state=link force=yes backup=yes - name: Set default system language pack shell: locale-gen {{server.locale}} - sudo: yes diff --git a/ansible/roles/xdebug/tasks/main.yml b/ansible/roles/xdebug/tasks/main.yml index e38815d..380ee2b 100755 --- a/ansible/roles/xdebug/tasks/main.yml +++ b/ansible/roles/xdebug/tasks/main.yml @@ -1,4 +1,3 @@ --- - name: Install xDebug - sudo: yes apt: pkg=php5-xdebug state=latest From 1866e5a0139c0f7c0b53d053909812485c9efccc Mon Sep 17 00:00:00 2001 From: Nikita Strelkov Date: Wed, 5 Oct 2016 21:53:43 +0500 Subject: [PATCH 07/10] Remove installation of php-zip and install composer packages from source --- ansible/roles/composer/tasks/main.yml | 7 ++++++- ansible/vars/all.yml | 4 ---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/ansible/roles/composer/tasks/main.yml b/ansible/roles/composer/tasks/main.yml index 4d362c3..27df507 100644 --- a/ansible/roles/composer/tasks/main.yml +++ b/ansible/roles/composer/tasks/main.yml @@ -1,5 +1,10 @@ - name: Install Composer shell: curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer creates=/usr/local/bin/composer +- name: Increase process timeout + shell: composer --global config process-timeout {{ composer.timeout }} + - name: Install packages - shell: cd /vagrant && composer install --optimize-autoloader + shell: composer install --optimize-autoloader --prefer-source + args: + chdir: /vagrant \ No newline at end of file diff --git a/ansible/vars/all.yml b/ansible/vars/all.yml index 1d0e7d2..d479a6b 100755 --- a/ansible/vars/all.yml +++ b/ansible/vars/all.yml @@ -19,10 +19,6 @@ php: - php7.0-json - php7.0-xml - php7.0-mbstring - pecl_packages: [php-zip] xdebug: install: '1' - -composer: - timeout: '2000' \ No newline at end of file From 9a10aa5d6220c4b96fdeb085c84bf16b2cb72a37 Mon Sep 17 00:00:00 2001 From: Nikita Strelkov Date: Wed, 5 Oct 2016 22:09:46 +0500 Subject: [PATCH 08/10] Revert accidentally deleted parameter composer.timeout --- ansible/vars/all.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ansible/vars/all.yml b/ansible/vars/all.yml index d479a6b..dc74d7f 100755 --- a/ansible/vars/all.yml +++ b/ansible/vars/all.yml @@ -22,3 +22,6 @@ php: xdebug: install: '1' + +composer: + timeout: 2400 \ No newline at end of file From fb1dd53e817f3ccc8e8c3173efaa59e6e704a880 Mon Sep 17 00:00:00 2001 From: Nikita Strelkov Date: Wed, 5 Oct 2016 22:24:20 +0500 Subject: [PATCH 09/10] Make lists of params more readable and remove useless vagrant_local params --- ansible/vars/all.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ansible/vars/all.yml b/ansible/vars/all.yml index dc74d7f..25f56c7 100755 --- a/ansible/vars/all.yml +++ b/ansible/vars/all.yml @@ -1,12 +1,20 @@ --- server: install: '1' - packages: [vim, htop, iotop, bwm-ng, git] + packages: + - vim + - htop + - iotop + - bwm-ng + - git timezone: UTC locale: en_US.UTF-8 + vagrant_local: install: '1' - vm: { base_box: trusty64, hostname: design-patterns, ip: 192.168.11.2, sharedfolder: ./, enableWindows: '1', useVagrantCloud: '1', syncType: nfs } + vm: + hostname: design-patterns + php: install: '1' ppa: php From e7f00225e62b7f317a9ff840468883438a22893b Mon Sep 17 00:00:00 2001 From: Nikita Strelkov Date: Mon, 10 Oct 2016 23:50:09 +0500 Subject: [PATCH 10/10] Use yml dictionaries for "lineinfile" to increase readabylity --- ansible/roles/php/tasks/php-cli.yml | 14 ++++++++------ ansible/roles/vagrant_local/tasks/main.yml | 8 +++++++- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/ansible/roles/php/tasks/php-cli.yml b/ansible/roles/php/tasks/php-cli.yml index 35b1daf..ae079f2 100755 --- a/ansible/roles/php/tasks/php-cli.yml +++ b/ansible/roles/php/tasks/php-cli.yml @@ -1,10 +1,12 @@ --- - name: enabling opcache cli - lineinfile: dest=/etc/php/7.0/cli/php.ini - regexp=';?opcache.enable=\d' - line='opcache.enable=1' + lineinfile: + dest: /etc/php/7.0/cli/php.ini + regexp: ';?opcache.enable=\d' + line: 'opcache.enable=1' - name: ensure timezone is set in cli php.ini - lineinfile: dest=/etc/php/7.0/cli/php.ini - regexp='date.timezone =' - line='date.timezone = {{ server.timezone }}' \ No newline at end of file + lineinfile: + dest: /etc/php/7.0/cli/php.ini + regexp: 'date.timezone =' + line: 'date.timezone = {{ server.timezone }}' \ No newline at end of file diff --git a/ansible/roles/vagrant_local/tasks/main.yml b/ansible/roles/vagrant_local/tasks/main.yml index cd53609..70cad53 100755 --- a/ansible/roles/vagrant_local/tasks/main.yml +++ b/ansible/roles/vagrant_local/tasks/main.yml @@ -8,4 +8,10 @@ when: vagrant_local.vm.hostname is defined - name: Update /etc/hosts - lineinfile: dest=/etc/hosts regexp='^127\.0\.0\.1' line='127.0.0.1 localhost {{ vagrant_local.vm.hostname }}' owner=root group=root mode=0644 + lineinfile: + dest: /etc/hosts + regexp: '^127\.0\.0\.1' + line: '127.0.0.1 localhost {{ vagrant_local.vm.hostname }}' + owner: root + group: root + mode: 0644