main.yml 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. ---
  2. # TODO: add validation for openshift_master_identity_providers
  3. # TODO: add ability to configure certificates given either a local file to
  4. # point to or certificate contents, set in default cert locations.
  5. - assert:
  6. that:
  7. - openshift_master_oauth_grant_method in openshift_master_valid_grant_methods
  8. when: openshift_master_oauth_grant_method is defined
  9. - name: Displaying openshift_master_ha
  10. debug: var=openshift_master_ha
  11. - name: openshift_master_cluster_password
  12. debug: var=openshift_master_cluster_password
  13. - name: openshift.master.cluster_defer_ha
  14. debug: var=openshift.master.cluster_defer_ha
  15. - fail:
  16. msg: "openshift_master_cluster_password must be set for multi-master installations"
  17. when: openshift_master_ha | bool and not openshift.master.cluster_defer_ha | bool and openshift_master_cluster_password is not defined
  18. - name: Set master facts
  19. openshift_facts:
  20. role: master
  21. local_facts:
  22. cluster_hostname: "{{ openshift_master_cluster_hostname | default(None) }}"
  23. cluster_public_hostname: "{{ openshift_master_cluster_public_hostname | default(None) }}"
  24. cluster_defer_ha: "{{ openshift_master_cluster_defer_ha | default(None) }}"
  25. debug_level: "{{ openshift_master_debug_level | default(openshift.common.debug_level) }}"
  26. api_port: "{{ openshift_master_api_port | default(None) }}"
  27. api_url: "{{ openshift_master_api_url | default(None) }}"
  28. api_use_ssl: "{{ openshift_master_api_use_ssl | default(None) }}"
  29. public_api_url: "{{ openshift_master_public_api_url | default('https://' ~ openshift.common.public_ip ~ ':8443') }}"
  30. console_path: "{{ openshift_master_console_path | default(None) }}"
  31. console_port: "{{ openshift_master_console_port | default(None) }}"
  32. console_url: "{{ openshift_master_console_url | default(None) }}"
  33. console_use_ssl: "{{ openshift_master_console_use_ssl | default(None) }}"
  34. public_console_url: "{{ openshift_master_public_console_url | default(None) }}"
  35. etcd_hosts: "{{ openshift_master_etcd_hosts | default(None)}}"
  36. etcd_port: "{{ openshift_master_etcd_port | default(None) }}"
  37. etcd_use_ssl: "{{ openshift_master_etcd_use_ssl | default(None) }}"
  38. etcd_urls: "{{ openshift_master_etcd_urls | default(None) }}"
  39. embedded_etcd: "{{ openshift_master_embedded_etcd | default(None) }}"
  40. embedded_kube: "{{ openshift_master_embedded_kube | default(None) }}"
  41. embedded_dns: "{{ openshift_master_embedded_dns | default(None) }}"
  42. dns_port: "{{ openshift_master_dns_port | default(None) }}"
  43. bind_addr: "{{ openshift_master_bind_addr | default(None) }}"
  44. portal_net: "{{ openshift_master_portal_net | default(None) }}"
  45. session_max_seconds: "{{ openshift_master_session_max_seconds | default(None) }}"
  46. session_name: "{{ openshift_master_session_name | default(None) }}"
  47. session_secrets_file: "{{ openshift_master_session_secrets_file | default(None) }}"
  48. access_token_max_seconds: "{{ openshift_master_access_token_max_seconds | default(None) }}"
  49. auth_token_max_seconds: "{{ openshift_master_auth_token_max_seconds | default(None) }}"
  50. identity_providers: "{{ openshift_master_identity_providers | default(None) }}"
  51. registry_url: "{{ oreg_url | default(None) }}"
  52. oauth_grant_method: "{{ openshift_master_oauth_grant_method | default(None) }}"
  53. sdn_cluster_network_cidr: "{{ osm_cluster_network_cidr | default(None) }}"
  54. sdn_host_subnet_length: "{{ osm_host_subnet_length | default(None) }}"
  55. default_subdomain: "{{ osm_default_subdomain | default(None) }}"
  56. custom_cors_origins: "{{ osm_custom_cors_origins | default(None) }}"
  57. default_node_selector: "{{ osm_default_node_selector | default(None) }}"
  58. api_server_args: "{{ osm_api_server_args | default(None) }}"
  59. controller_args: "{{ osm_controller_args | default(None) }}"
  60. - name: Install Master package
  61. yum: pkg={{ openshift.common.service_type }}-master{{ openshift_version }} state=present
  62. register: install_result
  63. - name: Check for RPM generated config marker file /etc/origin/.config_managed
  64. stat: path=/etc/origin/.rpmgenerated
  65. register: rpmgenerated_config
  66. - name: Remove RPM generated config files
  67. file:
  68. path: "{{ item }}"
  69. state: absent
  70. when: openshift.common.service_type in ['atomic-enterprise','openshift-enterprise'] and rpmgenerated_config.stat.exists == true
  71. with_items:
  72. - "{{ openshift.common.config_base }}/master"
  73. - "{{ openshift.common.config_base }}/node"
  74. - "{{ openshift.common.config_base }}/.rpmgenerated"
  75. # TODO: These values need to be configurable
  76. - name: Set dns facts
  77. openshift_facts:
  78. role: dns
  79. local_facts:
  80. ip: "{{ openshift_master_cluster_vip | default(openshift.common.ip, true) | default(None) }}"
  81. domain: cluster.local
  82. when: openshift.master.embedded_dns
  83. - name: Create config parent directory if it doesn't exist
  84. file:
  85. path: "{{ openshift_master_config_dir }}"
  86. state: directory
  87. - name: Create the policy file if it does not already exist
  88. command: >
  89. {{ openshift.common.admin_binary }} create-bootstrap-policy-file
  90. --filename={{ openshift_master_policy }}
  91. args:
  92. creates: "{{ openshift_master_policy }}"
  93. notify:
  94. - restart master
  95. - name: Create the scheduler config
  96. template:
  97. dest: "{{ openshift_master_scheduler_conf }}"
  98. src: scheduler.json.j2
  99. notify:
  100. - restart master
  101. - name: Install httpd-tools if needed
  102. yum: pkg=httpd-tools state=present
  103. when: item.kind == 'HTPasswdPasswordIdentityProvider'
  104. with_items: openshift.master.identity_providers
  105. - name: Ensure htpasswd directory exists
  106. file:
  107. path: "{{ item.filename | dirname }}"
  108. state: directory
  109. when: item.kind == 'HTPasswdPasswordIdentityProvider'
  110. with_items: openshift.master.identity_providers
  111. - name: Create the htpasswd file if needed
  112. copy:
  113. dest: "{{ item.filename }}"
  114. content: ""
  115. mode: 0600
  116. force: no
  117. when: item.kind == 'HTPasswdPasswordIdentityProvider'
  118. with_items: openshift.master.identity_providers
  119. # TODO: add the validate parameter when there is a validation command to run
  120. - name: Create master config
  121. template:
  122. dest: "{{ openshift_master_config_file }}"
  123. src: master.yaml.v1.j2
  124. notify:
  125. - restart master
  126. - name: Configure master settings
  127. lineinfile:
  128. dest: /etc/sysconfig/{{ openshift.common.service_type }}-master
  129. regexp: "{{ item.regex }}"
  130. line: "{{ item.line }}"
  131. with_items:
  132. - regex: '^OPTIONS='
  133. line: "OPTIONS=--loglevel={{ openshift.master.debug_level }}"
  134. - regex: '^CONFIG_FILE='
  135. line: "CONFIG_FILE={{ openshift_master_config_file }}"
  136. notify:
  137. - restart master
  138. - name: Start and enable master
  139. service: name={{ openshift.common.service_type }}-master enabled=yes state=started
  140. when: not openshift_master_ha | bool
  141. register: start_result
  142. - name: pause to prevent service restart from interfering with bootstrapping
  143. pause: seconds=30
  144. when: start_result | changed
  145. - name: Install cluster packages
  146. yum: pkg=pcs state=present
  147. when: openshift_master_ha | bool and not openshift.master.cluster_defer_ha | bool
  148. register: install_result
  149. - name: Start and enable cluster service
  150. service: name=pcsd enabled=yes state=started
  151. when: openshift_master_ha | bool and not openshift.master.cluster_defer_ha | bool
  152. - name: Set the cluster user password
  153. shell: echo {{ openshift_master_cluster_password | quote }} | passwd --stdin hacluster
  154. when: install_result | changed
  155. - name: Create the client config dir(s)
  156. file:
  157. path: "~{{ item }}/.kube"
  158. state: directory
  159. mode: 0700
  160. owner: "{{ item }}"
  161. group: "{{ item }}"
  162. with_items:
  163. - root
  164. - "{{ ansible_ssh_user }}"
  165. # TODO: Update this file if the contents of the source file are not present in
  166. # the dest file, will need to make sure to ignore things that could be added
  167. - name: Copy the admin client config(s)
  168. command: cp {{ openshift_master_config_dir }}/admin.kubeconfig ~{{ item }}/.kube/config
  169. args:
  170. creates: ~{{ item }}/.kube/config
  171. with_items:
  172. - root
  173. - "{{ ansible_ssh_user }}"
  174. - name: Update the permissions on the admin client config(s)
  175. file:
  176. path: "~{{ item }}/.kube/config"
  177. state: file
  178. mode: 0700
  179. owner: "{{ item }}"
  180. group: "{{ item }}"
  181. with_items:
  182. - root
  183. - "{{ ansible_ssh_user }}"