-
Notifications
You must be signed in to change notification settings - Fork 1
/
cloud-config.template
47 lines (45 loc) · 1.37 KB
/
cloud-config.template
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#cloud-config
write_files:
%{ if ansible_config != "" ~}
- path: /etc/ansible/ansible.cfg
owner: root:root
permissions: '0644'
content: ${ansible_config_esc}
%{ endif ~}
%{ if length(ansible_requirements) != 0 ~}
- path: /etc/ansible/requirements.yml
owner: root:root
permissions: '0644'
content: |
${ansible_requirements_esc}
%{ endif ~}
%{ if length(python_requirements) != 0 ~}
- path: /etc/ansible/python-requirements.txt
owner: root:root
permissions: '0644'
content: ${python_requirements_esc}
%{ endif ~}
- path: /etc/ansible/vars.yml
owner: root:root
permissions: '0644'
content: |
${ansible_variables}
- path: /etc/ansible/playbook.yml
owner: root:root
permissions: '0644'
content: |
- hosts: localhost
connection: local
vars_files: [/etc/ansible/vars.yml]
roles: ${ansible_playbook_roles}
runcmd:
%{ if create_ansible_directory ~}
- ${python} -m venv ${ansible_directory}
%{ endif ~}
%{ if length(python_requirements) != 0 ~}
- ${ansible_directory}/bin/pip install -r /etc/ansible/python-requirements.txt
%{ endif ~}
%{ if length(ansible_requirements) != 0 ~}
- ${ansible_directory}/bin/ansible-galaxy install -r /etc/ansible/requirements.yml -p /etc/ansible/roles
%{ endif ~}
- ${ansible_environment}${ansible_directory}/bin/ansible-playbook /etc/ansible/playbook.yml