main.yml 6.0 KB

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