aboutsummaryrefslogtreecommitdiffstats
path: root/common/deploy-steps-tasks.yaml
blob: 73d3036cf4d871afb74cf8b9e8efaa63fda32299 (plain)
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
    # Note the indentation here is required as it's joined
    # to create a playbook in deploy-steps.j2
   
    #####################################################
    # Per step puppet configuration of the baremetal host
    #####################################################
    - name: Write the config_step hieradata
      copy: content="{{dict(step=step|int)|to_json}}" dest=/etc/puppet/hieradata/config_step.json force=true mode=0600
    - name: Run puppet host configuration for step {{step}}
      command: >-
        puppet apply
        --modulepath=/etc/puppet/modules:/opt/stack/puppet-modules:/usr/share/openstack-puppet/modules
        --logdest syslog --logdest console --color=false
        /var/lib/tripleo-config/puppet_step_config.pp
      changed_when: false
      check_mode: no
      register: outputs
      failed_when: false
      no_log: true
    - debug: var=(outputs.stderr|default('')).split('\n')|union(outputs.stdout_lines|default([]))
      when: outputs is defined
      failed_when: outputs|failed
    ######################################
    # Generate config via docker-puppet.py
    ######################################
    - name: Run docker-puppet tasks (generate config)
      shell: python /var/lib/docker-puppet/docker-puppet.py
      environment:
        NET_HOST: 'true'
        DEBUG: '{{docker_puppet_debug|default(false)}}'
        PROCESS_COUNT: '{{docker_puppet_process_count|default(3)}}'
      when: step == "1"
      changed_when: false
      check_mode: no
      register: outputs
      failed_when: false
      no_log: true
    - debug: var=(outputs.stderr|default('')).split('\n')|union(outputs.stdout_lines|default([]))
      when: outputs is defined
      failed_when: outputs|failed
    ##################################################
    # Per step starting of the containers using paunch
    ##################################################
    - name: Check if /var/lib/hashed-tripleo-config/docker-container-startup-config-step_{{step}}.json exists
      stat:
        path: /var/lib/tripleo-config/hashed-docker-container-startup-config-step_{{step}}.json
      register: docker_config_json
    # Note docker-puppet.py generates the hashed-*.json file, which is a copy of
    # the *step_n.json with a hash of the generated external config added
    # This acts as a salt to enable restarting the container if config changes
    - name: Start containers for step {{step}}
      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}}
      when: docker_config_json.stat.exists
      changed_when: false
      check_mode: no
      register: outputs
      failed_when: false
      no_log: true
    - debug: var=(outputs.stderr|default('')).split('\n')|union(outputs.stdout_lines|default([]))
      when: outputs is defined
      failed_when: outputs|failed
    ########################################################
    # Bootstrap tasks, only performed on bootstrap_server_id
    ########################################################
    - name: Check if /var/lib/docker-puppet/docker-puppet-tasks{{step}}.json exists
      stat:
        path: /var/lib/docker-puppet/docker-puppet-tasks{{step}}.json
      register: docker_puppet_tasks_json
    - name: Run docker-puppet tasks (bootstrap tasks)
      shell: python /var/lib/docker-puppet/docker-puppet.py
      environment:
        CONFIG: /var/lib/docker-puppet/docker-puppet-tasks{{step}}.json
        NET_HOST: "true"
        NO_ARCHIVE: "true"
        STEP: "{{step}}"
      when: deploy_server_id == bootstrap_server_id and docker_puppet_tasks_json.stat.exists
      changed_when: false
      check_mode: no
      register: outputs
      failed_when: false
      no_log: true
    - debug: var=(outputs.stderr|default('')).split('\n')|union(outputs.stdout_lines|default([]))
      when: outputs is defined
      failed_when: outputs|failed