b3cb500fee890db0454a29c2b5bc14e740e80c0e
[apex-tripleo-heat-templates.git] / docker / deploy-steps-playbook.yaml
1 - hosts: localhost
2   connection: local
3   tasks:
4     #####################################################
5     # Per step puppet configuration of the baremetal host
6     #####################################################
7     - name: Write the config_step hieradata
8       copy: content="{{dict(step=step|int)|to_json}}" dest=/etc/puppet/hieradata/config_step.json force=true
9     - name: Run puppet host configuration for step {{step}}
10       # FIXME: modulepath requires ansible 2.4, our builds currently only have 2.3
11       # puppet: manifest=/var/lib/tripleo-config/puppet_step_config.pp modulepath=/etc/puppet/modules:/opt/stack/puppet-modules:/usr/share/openstack-puppet/modules
12       puppet: manifest=/var/lib/tripleo-config/puppet_step_config.pp
13     ######################################
14     # Generate config via docker-puppet.py
15     ######################################
16     - name: Run docker-puppet tasks (generate config)
17       shell: python /var/lib/docker-puppet/docker-puppet.py
18       environment:
19         NET_HOST: 'true'
20       when: step == "1"
21       changed_when: false
22       check_mode: no
23     ##################################################
24     # Per step starting of the containers using paunch
25     ##################################################
26     - name: Check if /var/lib/hashed-tripleo-config/docker-container-startup-config-step_{{step}}.json exists
27       stat:
28         path: /var/lib/tripleo-config/hashed-docker-container-startup-config-step_{{step}}.json
29       register: docker_config_json
30     # Note docker-puppet.py generates the hashed-*.json file, which is a copy of
31     # the *step_n.json with a hash of the generated external config added
32     # This acts as a salt to enable restarting the container if config changes
33     - name: Start containers for step {{step}}
34       command: paunch --debug apply --file /var/lib/tripleo-config/hashed-docker-container-startup-config-step_{{step}}.json --config-id tripleo_step{{step}} --managed-by tripleo-{{role_name}}
35       when: docker_config_json.stat.exists
36       changed_when: false
37       check_mode: no
38     ########################################################
39     # Bootstrap tasks, only performed on bootstrap_server_id
40     ########################################################
41     - name: Run docker-puppet tasks (bootstrap tasks)
42       shell: python /var/lib/docker-puppet/docker-puppet.py
43       environment:
44         CONFIG: /var/lib/docker-puppet/docker-puppet-tasks{{step}}.json
45         NET_HOST: "true"
46         NO_ARCHIVE: "true"
47         STEP: "{{step}}"
48       when: deploy_server_id == bootstrap_server_id
49       changed_when: false
50       check_mode: no