config.yml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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 registering the nodes before they are configured, we
  8. # need to make sure to set the node properties beforehand if we do not want
  9. # 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. - role: node
  19. local_facts:
  20. external_id: "{{ openshift_node_external_id | default(None) }}"
  21. resources_cpu: "{{ openshift_node_resources_cpu | default(None) }}"
  22. resources_memory: "{{ openshift_node_resources_memory | default(None) }}"
  23. pod_cidr: "{{ openshift_node_pod_cidr | default(None) }}"
  24. labels: "{{ openshift_node_labels | default(None) }}"
  25. annotations: "{{ openshift_node_annotations | default(None) }}"
  26. deployment_type: "{{ openshift_deployment_type }}"
  27. - name: Create temp directory for syncing certs
  28. hosts: localhost
  29. gather_facts: no
  30. tasks:
  31. - name: Create local temp directory for syncing certs
  32. local_action: command mktemp -d /tmp/openshift-ansible-XXXXXXX
  33. register: mktemp
  34. changed_when: False
  35. - name: Register nodes
  36. hosts: oo_first_master
  37. vars:
  38. openshift_nodes: "{{ hostvars | oo_select_keys(groups['oo_nodes_to_config']) }}"
  39. sync_tmpdir: "{{ hostvars.localhost.mktemp.stdout }}"
  40. roles:
  41. - openshift_register_nodes
  42. tasks:
  43. # TODO: update so that we only sync necessary configs/directories, currently
  44. # we sync for all nodes in oo_nodes_to_config. We will need to inspect the
  45. # configs on the nodes to make the determination on whether to sync or not.
  46. - name: Create the temp directory on the master
  47. file:
  48. path: "{{ sync_tmpdir }}"
  49. owner: "{{ ansible_ssh_user }}"
  50. mode: 0700
  51. state: directory
  52. changed_when: False
  53. - name: Create a tarball of the node config directories
  54. command: tar -czvf {{ sync_tmpdir }}/{{ item.openshift.common.hostname }}.tgz ./
  55. args:
  56. chdir: "{{ openshift_cert_dir }}/node-{{ item.openshift.common.hostname }}"
  57. with_items: openshift_nodes
  58. changed_when: False
  59. - name: Retrieve the node config tarballs from the master
  60. fetch:
  61. src: "{{ sync_tmpdir }}/{{ item.openshift.common.hostname }}.tgz"
  62. dest: "{{ sync_tmpdir }}/"
  63. flat: yes
  64. fail_on_missing: yes
  65. validate_checksum: yes
  66. with_items: openshift_nodes
  67. changed_when: False
  68. - name: Remove the temp directory on the master
  69. file:
  70. path: "{{ sync_tmpdir }}"
  71. state: absent
  72. changed_when: False
  73. - name: Configure node instances
  74. hosts: oo_nodes_to_config
  75. gather_facts: no
  76. vars:
  77. sync_tmpdir: "{{ hostvars.localhost.mktemp.stdout }}"
  78. openshift_sdn_master_url: "https://{{ hostvars[groups['oo_first_master'][0]].openshift.common.hostname }}:4001"
  79. pre_tasks:
  80. - name: Ensure certificate directory exists
  81. file:
  82. path: "{{ openshift_node_cert_dir }}"
  83. state: directory
  84. # TODO: notify restart openshift-node and/or restart openshift-sdn-node,
  85. # possibly test service started time against certificate/config file
  86. # timestamps in openshift-node or openshift-sdn-node to trigger notify
  87. - name: Unarchive the tarball on the node
  88. unarchive:
  89. src: "{{ sync_tmpdir }}/{{ openshift.common.hostname }}.tgz"
  90. dest: "{{ openshift_node_cert_dir }}"
  91. roles:
  92. - openshift_node
  93. - { role: openshift_sdn_node, when: openshift.common.use_openshift_sdn | bool }
  94. tasks:
  95. - name: Create group for deployment type
  96. group_by: key=oo_nodes_deployment_type_{{ openshift.common.deployment_type }}
  97. changed_when: False
  98. - name: Delete temporary directory
  99. hosts: localhost
  100. gather_facts: no
  101. tasks:
  102. - file: name={{ mktemp.stdout }} state=absent
  103. changed_when: False
  104. # Additional config for online type deployments
  105. - name: Additional instance config
  106. hosts: oo_nodes_deployment_type_online
  107. gather_facts: no
  108. roles:
  109. - os_env_extras
  110. - os_env_extras_node