Skip to content

Commit 14f7d9e

Browse files
committed
Make provisioning playbook more generic
1 parent d26bd0f commit 14f7d9e

File tree

7 files changed

+37
-33
lines changed

7 files changed

+37
-33
lines changed

Vagrantfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
1919
end
2020
contrail_sandbox_config.vm.provision "ansible" do |ansible|
2121
ansible.playbook = "provisioning/site.yaml"
22-
#ansible.verbose = "vvv"
22+
ansible.verbose = "v"
2323
end
2424
end
2525
end

provisioning/roles/checkout_repos/tasks/main.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
- name: Checkout CI jobs repos
22
git:
33
repo: "https://github.com/{{ item.user }}/{{ item.reponame }}"
4-
dest: "/home/vagrant/code/{{ item.reponame }}"
5-
version: "{{ item.version | default('master') }}"
4+
dest: "{{ workdir }}/code/{{ item.reponame }}"
5+
version: master
66
with_items:
77
- { user: 'jluk-codi', reponame: 'contrail-project-config', version: devenv }
88
- { user: 'codilime', reponame: 'zuul-jobs' }

provisioning/roles/setup_docker/tasks/main.yaml

+8-8
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@
1616

1717
- name: Prepare share volume for HTTP server
1818
file:
19-
path: "/home/vagrant/rpmbuild/RPMS"
19+
path: "{{ workdir }}/rpmbuild/RPMS"
2020
state: directory
2121
mode: 0755
22-
owner: vagrant
23-
group: vagrant
22+
owner: "{{ sandbox_owner }}"
23+
group: "{{ sandbox_group }}"
2424

2525
- name: Prepare config directory for contenaraized HTTP server
2626
copy:
2727
src: "../templates/lighttpd"
28-
dest: "/home/vagrant/"
28+
dest: "{{ workdir }}/"
2929
mode: 0644
30-
owner: vagrant
31-
group: vagrant
30+
owner: "{{ sandbox_owner }}"
31+
group: "{{ sandbox_group }}"
3232

3333
- name: Start lighttpd container
3434
docker_container:
@@ -39,8 +39,8 @@
3939
expose:
4040
- 80
4141
volumes:
42-
- /home/vagrant/rpmbuild/RPMS:/var/www/localhost/htdocs:Z
43-
- /home/vagrant/lighttpd:/etc/lighttpd:Z
42+
- "{{ workdir }}/rpmbuild/RPMS:/var/www/localhost/htdocs:Z"
43+
- "{{ workdir }}/lighttpd:/etc/lighttpd:Z"
4444
become: yes
4545
become_user: root
4646

Original file line numberDiff line numberDiff line change
@@ -1,29 +1,27 @@
11
- name: Prepare inventory hosts.yaml used by CI playbooks
22
copy:
33
src: "../templates/inventory"
4-
dest: "/home/vagrant/code"
4+
dest: "{{ workdir }}/code"
55
mode: 0644
6-
owner: vagrant
7-
group: vagrant
6+
owner: "{{ sandbox_owner }}"
7+
group: "{{ sandbox_group }}"
88

99
- name: Setup config file for Ansible run inside VM
10-
copy:
11-
content: |
12-
[defaults]
13-
roles_path = /home/vagrant/code/contrail-project-config/roles:/home/vagrant/code/zuul-jobs/roles
14-
dest: /home/vagrant/.ansible.cfg
10+
template:
11+
src: "../templates/ansible.cfg.j2"
12+
dest: "{{ workdir }}/.ansible.cfg"
1513
mode: 0644
16-
owner: vagrant
17-
group: vagrant
14+
owner: "{{ sandbox_owner }}"
15+
group: "{{ sandbox_group }}"
1816

1917

2018
- name: Create sandbox dir
2119
file:
22-
path: "/home/vagrant/contrail-5.0"
20+
path: "{{ workdir }}/contrail-5.0"
2321
state: directory
2422
mode: 0755
25-
owner: vagrant
26-
group: vagrant
23+
owner: "{{ sandbox_owner }}"
24+
group: "{{ sandbox_group }}"
2725

2826
- name: Configure git client
2927
git_config:
@@ -39,11 +37,11 @@
3937
shell: |
4038
repo init --no-clone-bundle -u https://github.com/Juniper/contrail-vnc -b master
4139
args:
42-
chdir: /home/vagrant/contrail-5.0
40+
chdir: "{{ workdir }}/contrail-5.0"
4341

4442
- name: Sychronize repo dir with upstream
4543
shell: |
4644
repo sync --no-clone-bundle -j 4
4745
args:
48-
chdir: /home/vagrant/contrail-5.0
46+
chdir: "{{ workdir }}/contrail-5.0"
4947

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[defaults]
2+
roles_path = "{{ workdir}}/code/contrail-project-config/roles:{{ workdir }}/code/zuul-jobs/roles"

provisioning/roles/setup_sandbox/templates/inventory/ansible.cfg

-2
This file was deleted.

provisioning/site.yaml

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
- hosts: contrail_sandbox
2+
vars:
3+
workdir: '/home/vagrant'
4+
sandbox_owner: 'vagrant'
5+
sandbox_group: 'vagrant'
6+
remote_user: vagrant
27
roles:
3-
- generic_dependencies
4-
- build_dependencies
5-
- checkout_repos
6-
- setup_sandbox
7-
- setup_docker
8+
- role: generic_dependencies
9+
- role: build_dependencies
10+
- role: checkout_repos
11+
- role: setup_sandbox
12+
- role: setup_docker
13+

0 commit comments

Comments
 (0)