main.yml 6.8 KB

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