Skip to content

Transfer ansible playbooks to roles #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Installation
* Install [VirtualBox](https://www.virtualbox.org/)
* Install vagrant using the installation instructions in the [Getting Started document](https://www.vagrantup.com/docs/getting-started/)
* Clone this repository and cd into it
* Run ```vagrant up``` in order to set up the box using the ansible provisioner
* Run ```vagrant up``` in order to set up the box using the ```ansible_local``` provisioner
* You should now have your working
* Symfony2 Standard Edition under http://192.168.50.4:8081/
* Laravel Quickstart example app under http://192.168.50.4:8082/
Expand Down Expand Up @@ -43,9 +43,12 @@ Changes
-------

### unreleased

* Transfer ansible playbooks to roles #31

### v1.3.0

* Switch provisioner to ansible
* Switch provisioner to ansible #18

### v1.0.0

Expand Down
3 changes: 2 additions & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ Vagrant.configure(2) do |config|
# See https://github.com/mitchellh/vagrant/issues/5005
config.ssh.insert_key = false

config.vm.provision "ansible" do |ansible|
# Run Ansible from the Vagrant VM
config.vm.provision "ansible_local" do |ansible|
ansible.verbose = "vv"
ansible.playbook = "playbooks/vagrant.yml"
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
with_items:
- curl
- git
- python-mysqldb
- python-mysqldb
- zip
- unzip
6 changes: 6 additions & 0 deletions playbooks/roles/laravel-quickstart/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
dependencies:
- { role: base }
- { role: mysql }
- { role: php-fpm }
- { role: nginx }
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,41 @@
git: repo=https://github.com/laravel/quickstart-basic
dest=/vagrant/laravel-quickstart
update=no
become: true
become_user: "{{ www_user }}"

- name: Copy across new .env file
template:
src=laravel/.env.j2
src=.env.j2
dest=/vagrant/laravel-quickstart/.env

- stat: path=/vagrant/laravel-quickstart/vendor
register: p
become: true
become_user: "{{ www_user }}"

- name: Install Laravel project dependencies
shell: cd /vagrant/laravel-quickstart && composer install
when: p.stat.isdir is not defined
shell: cd /vagrant/laravel-quickstart && COMPOSER_PROCESS_TIMEOUT={{composer_process_timeout}} composer install
become: true
become_user: "{{ www_user }}"

- name: Generate laravel key
shell: cd /vagrant/laravel-quickstart && php artisan key:generate
become: true
become_user: "{{ www_user }}"

- name: Execute migrations for the quickstart example
shell: cd /vagrant/laravel-quickstart && php artisan migrate
become: true
become_user: "{{ www_user }}"

- name: Copy across new php-fpm pool config for laravel
template:
src=php-fpm/laravel.conf.j2
src=php-fpm.conf.j2
dest=/etc/php/5.6/fpm/pool.d/laravel.conf
notify:
- restart php-fpm

- name: Copy across new virtual host for laravel
template:
src=nginx/laravel.conf.j2
src=nginx.conf.j2
dest=/etc/nginx/sites-available/laravel.conf
notify:
- restart nginx
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions playbooks/roles/nginx/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- name: restart nginx
service: name=nginx state=restarted
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

- name: Copy across new nginx config
template:
src=nginx/nginx.conf.j2
src=nginx.conf.j2
dest=/etc/nginx/nginx.conf
notify:
- restart nginx
Expand Down
2 changes: 2 additions & 0 deletions playbooks/roles/php-fpm/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- name: restart php-fpm
service: name=php5.6-fpm state=restarted
3 changes: 3 additions & 0 deletions playbooks/roles/php-fpm/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
dependencies:
- { role: php }
File renamed without changes.
2 changes: 2 additions & 0 deletions playbooks/roles/php/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
composer_process_timeout: 900
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@
- php5.6-intl
- php5.6-cli
- php5.6-mcrypt
- php5.6-mbstring
- php5.6-dom

- name: Enable the MCrypt extension
shell: phpenmod mcrypt

- name: Install composer
shell: curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
shell: curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

- name: Configure composer cache directory to avoid using slow NFS
shell: composer config --global cache-dir /dev/shm/composer/cache
6 changes: 6 additions & 0 deletions playbooks/roles/symfony-standard/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
dependencies:
- { role: base }
- { role: mysql }
- { role: php-fpm }
- { role: nginx }
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,31 @@
git: repo=https://github.com/symfony/symfony-standard.git
dest=/vagrant/symfony-standard
update=no
become: true
become_user: "{{ www_user }}"

- name: Copy across new parameters.yml
template:
src=symfony/symfony_parameters.yml.j2
src=parameters.yml.j2
dest=/vagrant/symfony-standard/app/config/parameters.yml

- stat: path=/vagrant/symfony-standard/vendor
register: p
become: true
become_user: "{{ www_user }}"

- name: Install Symfony2 project dependencies
shell: cd /vagrant/symfony-standard && composer install
when: p.stat.isdir is not defined
shell: cd /vagrant/symfony-standard && COMPOSER_PROCESS_TIMEOUT={{composer_process_timeout}} composer install
become: true
become_user: "{{ www_user }}"

- name: Copy across new php-fpm pool config for symfony
template:
src=php-fpm/symfony.conf.j2
src=php-fpm.conf.j2
dest=/etc/php/5.6/fpm/pool.d/symfony.conf
notify:
- restart php-fpm

- name: Copy across new virtual host for symfony
template:
src=nginx/symfony.conf.j2
src=nginx.conf.j2
dest=/etc/nginx/sites-available/symfony.conf
notify:
- restart nginx
Expand Down
25 changes: 10 additions & 15 deletions playbooks/vagrant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,15 @@
document_root: /vagrant
www_user: vagrant
www_group: vagrant
handlers:
- name: restart nginx
service: name=nginx state=restarted
- name: restart php-fpm
service: name=php5.6-fpm state=restarted
pre_tasks:
- name: update apt cache
apt: update_cache=yes
tasks:
- include: tasks/base.yml
- include: tasks/nginx.yml
- include: tasks/mysql.yml
- include: tasks/php.yml
- include: tasks/php-devtools.yml
- include: tasks/php-fpm.yml
- include: tasks/symfony-standard.yml
- include: tasks/laravel-quickstart.yml
apt: update_cache=yes cache_valid_time=3600
roles:
- base
- nginx
- mysql
- php
- php-devtools
- php-fpm
- symfony-standard
- laravel-quickstart