Heat templates for deploying OpenStack
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

143 lines
5.2 KiB

  1. #####################################################
  2. # Per step puppet configuration of the baremetal host
  3. #####################################################
  4. - name: Write the config_step hieradata
  5. become: true
  6. no_log: True
  7. copy:
  8. content: "{{ dict(step=step|int) | to_json }}"
  9. dest: /etc/puppet/{{ ansible_check_mode | bool | ternary('check-mode/', '') }}hieradata/config_step.json
  10. force: true
  11. mode: '0600'
  12. check_mode: no
  13. tags:
  14. - host_config
  15. - name: Run puppet host configuration for step {{ step }}
  16. become: true
  17. async: 3600
  18. poll: 0
  19. when: enable_puppet|bool
  20. shell: >-
  21. set -o pipefail;
  22. puppet apply {{ host_puppet_config_debug | default('') }}
  23. --modulepath=/etc/puppet/modules:/opt/stack/puppet-modules:/usr/share/openstack-puppet/modules
  24. --detailed-exitcodes
  25. --summarize
  26. --color=false
  27. {{ ansible_check_mode | bool | ternary('--noop', '') }}
  28. {{ ansible_check_mode | bool | ternary('--hiera_config /etc/puppet/check-mode/hiera.yaml', '') }}
  29. /var/lib/tripleo-config/{{ ansible_check_mode | bool | ternary('check-mode/', '') }}puppet_step_config.pp
  30. 2>&1 | logger -s -t puppet-user
  31. register: puppet_host_async_result
  32. no_log: true
  33. tags:
  34. - host_config
  35. check_mode: no
  36. - name: Wait for puppet host configuration to finish
  37. async_status:
  38. jid: "{{ puppet_host_async_result.ansible_job_id }}"
  39. register: puppet_host_outputs
  40. until: puppet_host_outputs.finished
  41. retries: 1200
  42. delay: 3
  43. failed_when:
  44. - (not puppet_host_outputs.finished) or (puppet_host_outputs.rc is defined and puppet_host_outputs.rc not in [0, 2])
  45. when:
  46. - not (ansible_check_mode | bool)
  47. - enable_puppet|bool
  48. tags:
  49. - host_config
  50. - name: "Debug output for task: Run puppet host configuration for step {{ step }}"
  51. debug:
  52. var: puppet_host_outputs.stdout_lines | default([]) | union(puppet_host_outputs.stderr_lines | default([]))
  53. when:
  54. - not ansible_check_mode|bool
  55. - enable_puppet | bool
  56. - puppet_host_outputs.rc is defined
  57. changed_when: puppet_host_outputs.rc == 2
  58. failed_when: puppet_host_outputs.rc not in [0, 2]
  59. tags:
  60. - host_config
  61. #######################################
  62. # Pre-cache facts for puppet containers
  63. #######################################
  64. # We don't want the pre-cache tasks to be skipped in dry-run so we force
  65. # check_mode to "no".
  66. # https://bugzilla.redhat.com/show_bug.cgi?id=1738529
  67. - name: Pre-cache facts for puppet containers
  68. include_role:
  69. name: tripleo_puppet_cache
  70. tags:
  71. - container_config
  72. - container_config_tasks
  73. #######################################
  74. # Generate config via puppet containers
  75. #######################################
  76. - name: Include container-puppet tasks (generate config) during step 1
  77. include_tasks: generate-config-tasks.yaml
  78. when: step|int == 1
  79. tags:
  80. - container_config
  81. #####################################
  82. # Per step starting of the containers
  83. #####################################
  84. - name: Per step starting of the containers using tripleo-ansible
  85. become: true
  86. environment:
  87. TRIPLEO_MINOR_UPDATE: '{{ tripleo_minor_update | default(false) }}'
  88. block:
  89. - name: "Manage containers for step {{ step }} with tripleo-ansible"
  90. include_role:
  91. name: tripleo_container_manage
  92. vars:
  93. tripleo_container_manage_concurrency: 5
  94. tripleo_container_manage_systemd_order: true
  95. tripleo_container_manage_cli: "{{ container_cli }}"
  96. tripleo_container_manage_config: "/var/lib/tripleo-config/container-startup-config/step_{{ step }}"
  97. tripleo_container_manage_config_id: "tripleo_step{{ step }}"
  98. tripleo_container_manage_debug: "{{ enable_debug | bool }}"
  99. tripleo_container_manage_healthcheck_disabled: "{{ container_healthcheck_disabled | bool }}"
  100. tripleo_container_manage_log_path: "{{ container_log_stdout_path }}"
  101. tripleo_container_manage_config_patterns: '*.json'
  102. tripleo_container_manage_check_puppet_config: true
  103. tripleo_container_manage_valid_exit_code: [0]
  104. tags:
  105. - container_startup_configs
  106. ########################################################
  107. # Bootstrap tasks - run any tasks that have been defined
  108. ########################################################
  109. - name: "Clean container_puppet_tasks for {{ansible_hostname | lower}} step {{step}}"
  110. become: true
  111. file:
  112. path: /var/lib/container-puppet/container-puppet-tasks{{step}}.json
  113. state: absent
  114. tags:
  115. - container_config_tasks
  116. - name: Calculate container_puppet_tasks for {{ansible_hostname | lower}} step {{step}}
  117. set_fact:
  118. "{{'host_container_puppet_tasks_' ~ step}}": "{{lookup('vars', 'host_container_puppet_tasks_' ~ step, default=[]) | union([item])}}"
  119. loop: "{{container_puppet_tasks.get('step_' ~ step, [])}}"
  120. when: (groups[item.service_name] | default ([]) | map('extract', hostvars, 'inventory_hostname') | sort | first | lower) == ansible_hostname | lower
  121. vars:
  122. container_puppet_tasks: "{{ lookup('file', tripleo_role_name + '/container_puppet_tasks.yaml', errors='ignore') | default({}, True) | from_yaml }}"
  123. tags:
  124. - container_config_tasks
  125. - name: Include container-puppet tasks for step {{step}}
  126. include_tasks: host-container-puppet-tasks.yaml
  127. when: ('host_container_puppet_tasks_' ~ step) is defined
  128. tags:
  129. - container_config_tasks