Skip to content

Commit 05c3a17

Browse files
committed
Transfer ansible playbooks to roles, closes #30
1 parent a501f47 commit 05c3a17

File tree

24 files changed

+68
-36
lines changed

24 files changed

+68
-36
lines changed

Readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Installation
88
* Install [VirtualBox](https://www.virtualbox.org/)
99
* Install vagrant using the installation instructions in the [Getting Started document](https://www.vagrantup.com/docs/getting-started/)
1010
* Clone this repository and cd into it
11-
* Run ```vagrant up``` in order to set up the box using the ansible provisioner
11+
* Run ```vagrant up``` in order to set up the box using the ```ansible_local``` provisioner
1212
* You should now have your working
1313
* Symfony2 Standard Edition under http://192.168.50.4:8081/
1414
* Laravel Quickstart example app under http://192.168.50.4:8082/

Vagrantfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ Vagrant.configure(2) do |config|
1010
# See https://github.com/mitchellh/vagrant/issues/5005
1111
config.ssh.insert_key = false
1212

13-
config.vm.provision "ansible" do |ansible|
13+
# Run Ansible from the Vagrant VM
14+
config.vm.provision "ansible_local" do |ansible|
1415
ansible.verbose = "vv"
1516
ansible.playbook = "playbooks/vagrant.yml"
1617
end

playbooks/tasks/base.yml renamed to playbooks/roles/base/tasks/main.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@
33
with_items:
44
- curl
55
- git
6-
- python-mysqldb
6+
- python-mysqldb
7+
- zip
8+
- unzip
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
dependencies:
3+
- { role: base }
4+
- { role: mysql }
5+
- { role: php-fpm }
6+
- { role: nginx }

playbooks/tasks/laravel-quickstart.yml renamed to playbooks/roles/laravel-quickstart/tasks/main.yml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,35 +9,41 @@
99
git: repo=https://github.com/laravel/quickstart-basic
1010
dest=/vagrant/laravel-quickstart
1111
update=no
12+
become: true
13+
become_user: "{{ www_user }}"
1214

1315
- name: Copy across new .env file
1416
template:
15-
src=laravel/.env.j2
17+
src=.env.j2
1618
dest=/vagrant/laravel-quickstart/.env
17-
18-
- stat: path=/vagrant/laravel-quickstart/vendor
19-
register: p
19+
become: true
20+
become_user: "{{ www_user }}"
2021

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

2527
- name: Generate laravel key
2628
shell: cd /vagrant/laravel-quickstart && php artisan key:generate
29+
become: true
30+
become_user: "{{ www_user }}"
2731

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

3137
- name: Copy across new php-fpm pool config for laravel
3238
template:
33-
src=php-fpm/laravel.conf.j2
39+
src=php-fpm.conf.j2
3440
dest=/etc/php/5.6/fpm/pool.d/laravel.conf
3541
notify:
3642
- restart php-fpm
3743

3844
- name: Copy across new virtual host for laravel
3945
template:
40-
src=nginx/laravel.conf.j2
46+
src=nginx.conf.j2
4147
dest=/etc/nginx/sites-available/laravel.conf
4248
notify:
4349
- restart nginx
File renamed without changes.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- name: restart nginx
2+
service: name=nginx state=restarted

0 commit comments

Comments
 (0)