config.yml 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. ---
  2. - name: Gather and set facts for node hosts
  3. hosts: oo_nodes_to_config
  4. roles:
  5. - openshift_facts
  6. tasks:
  7. # Since the master is generating the node certificates before they are
  8. # configured, we need to make sure to set the node properties beforehand if
  9. # we do not want the defaults
  10. - openshift_facts:
  11. role: "{{ item.role }}"
  12. local_facts: "{{ item.local_facts }}"
  13. with_items:
  14. - role: common
  15. local_facts:
  16. hostname: "{{ openshift_hostname | default(None) }}"
  17. public_hostname: "{{ openshift_public_hostname | default(None) }}"
  18. deployment_type: "{{ openshift_deployment_type }}"
  19. - role: node
  20. local_facts:
  21. labels: "{{ openshift_node_labels | default(None) }}"
  22. annotations: "{{ openshift_node_annotations | default(None) }}"
  23. schedulable: "{{ openshift_schedulable | default(openshift_scheduleable) | default(None) }}"
  24. - name: Check status of node certificates
  25. stat:
  26. path: "{{ openshift.common.config_base }}/node/{{ item }}"
  27. with_items:
  28. - "system:node:{{ openshift.common.hostname }}.crt"
  29. - "system:node:{{ openshift.common.hostname }}.key"
  30. - "system:node:{{ openshift.common.hostname }}.kubeconfig"
  31. - ca.crt
  32. - server.key
  33. - server.crt
  34. register: stat_result
  35. - set_fact:
  36. certs_missing: "{{ stat_result.results | map(attribute='stat.exists')
  37. | list | intersect([false])}}"
  38. node_subdir: node-{{ openshift.common.hostname }}
  39. config_dir: "{{ openshift.common.config_base }}/generated-configs/node-{{ openshift.common.hostname }}"
  40. node_cert_dir: "{{ openshift.common.config_base }}/node"
  41. - name: Create temp directory for syncing certs
  42. hosts: localhost
  43. connection: local
  44. sudo: false
  45. gather_facts: no
  46. tasks:
  47. - name: Create local temp directory for syncing certs
  48. local_action: command mktemp -d /tmp/openshift-ansible-XXXXXXX
  49. register: mktemp
  50. changed_when: False
  51. - name: Create node certificates
  52. hosts: oo_first_master
  53. vars:
  54. nodes_needing_certs: "{{ hostvars
  55. | oo_select_keys(groups['oo_nodes_to_config']
  56. | default([]))
  57. | oo_filter_list(filter_attr='certs_missing') }}"
  58. sync_tmpdir: "{{ hostvars.localhost.mktemp.stdout }}"
  59. roles:
  60. - openshift_node_certificates
  61. post_tasks:
  62. - name: Create a tarball of the node config directories
  63. command: >
  64. tar -czvf {{ item.config_dir }}.tgz
  65. --transform 's|system:{{ item.node_subdir }}|node|'
  66. -C {{ item.config_dir }} .
  67. args:
  68. creates: "{{ item.config_dir }}.tgz"
  69. with_items: nodes_needing_certs
  70. - name: Retrieve the node config tarballs from the master
  71. fetch:
  72. src: "{{ item.config_dir }}.tgz"
  73. dest: "{{ sync_tmpdir }}/"
  74. flat: yes
  75. fail_on_missing: yes
  76. validate_checksum: yes
  77. with_items: nodes_needing_certs
  78. - name: Configure node instances
  79. hosts: oo_nodes_to_config
  80. vars:
  81. sync_tmpdir: "{{ hostvars.localhost.mktemp.stdout }}"
  82. openshift_node_master_api_url: "{{ hostvars[groups.oo_first_master.0].openshift.master.api_url }}"
  83. pre_tasks:
  84. - name: Ensure certificate directory exists
  85. file:
  86. path: "{{ node_cert_dir }}"
  87. state: directory
  88. # TODO: notify restart node
  89. # possibly test service started time against certificate/config file
  90. # timestamps in node to trigger notify
  91. - name: Unarchive the tarball on the node
  92. unarchive:
  93. src: "{{ sync_tmpdir }}/{{ node_subdir }}.tgz"
  94. dest: "{{ node_cert_dir }}"
  95. when: certs_missing
  96. roles:
  97. - openshift_node
  98. - role: nickhammond.logrotate
  99. - role: fluentd_node
  100. when: openshift.common.use_fluentd | bool
  101. tasks:
  102. - name: Create group for deployment type
  103. group_by: key=oo_nodes_deployment_type_{{ openshift.common.deployment_type }}
  104. changed_when: False
  105. - name: Delete temporary directory on localhost
  106. hosts: localhost
  107. connection: local
  108. sudo: false
  109. gather_facts: no
  110. tasks:
  111. - file: name={{ mktemp.stdout }} state=absent
  112. changed_when: False
  113. # Additional config for online type deployments
  114. - name: Additional instance config
  115. hosts: oo_nodes_deployment_type_online
  116. gather_facts: no
  117. roles:
  118. - os_env_extras
  119. - os_env_extras_node
  120. - name: Set schedulability
  121. hosts: oo_first_master
  122. vars:
  123. openshift_nodes: "{{ hostvars
  124. | oo_select_keys(groups['oo_nodes_to_config'])
  125. | oo_collect('openshift.common.hostname') }}"
  126. openshift_node_vars: "{{ hostvars | oo_select_keys(groups['oo_nodes_to_config']) }}"
  127. pre_tasks:
  128. roles:
  129. - openshift_manage_node