main.yml 6.2 KB

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