main.yml 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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: "{{ openshift_master_etcd_hosts | 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 policy file if it does not already exist
  59. command: >
  60. {{ openshift.common.admin_binary }} create-bootstrap-policy-file
  61. --filename={{ openshift_master_policy }}
  62. args:
  63. creates: "{{ openshift_master_policy }}"
  64. notify:
  65. - restart openshift-master
  66. - name: Create the scheduler config
  67. template:
  68. dest: "{{ openshift_master_scheduler_conf }}"
  69. src: scheduler.json.j2
  70. notify:
  71. - restart openshift-master
  72. - name: Install httpd-tools if needed
  73. yum: pkg=httpd-tools state=present
  74. when: item.kind == 'HTPasswdPasswordIdentityProvider'
  75. with_items: openshift.master.identity_providers
  76. - name: Create the htpasswd file if needed
  77. copy:
  78. dest: "{{ item.filename }}"
  79. content: ""
  80. mode: 0600
  81. force: no
  82. when: item.kind == 'HTPasswdPasswordIdentityProvider'
  83. with_items: openshift.master.identity_providers
  84. # TODO: add the validate parameter when there is a validation command to run
  85. - name: Create master config
  86. template:
  87. dest: "{{ openshift_master_config_file }}"
  88. src: master.yaml.v1.j2
  89. notify:
  90. - restart openshift-master
  91. - name: Configure OpenShift settings
  92. lineinfile:
  93. dest: /etc/sysconfig/openshift-master
  94. regexp: "{{ item.regex }}"
  95. line: "{{ item.line }}"
  96. with_items:
  97. - regex: '^OPTIONS='
  98. line: "OPTIONS=--loglevel={{ openshift.master.debug_level }}"
  99. - regex: '^CONFIG_FILE='
  100. line: "CONFIG_FILE={{ openshift_master_config_file }}"
  101. notify:
  102. - restart openshift-master
  103. - name: Start and enable openshift-master
  104. service: name=openshift-master enabled=yes state=started
  105. - name: Create the OpenShift client config dir(s)
  106. file:
  107. path: "~{{ item }}/.kube"
  108. state: directory
  109. mode: 0700
  110. owner: "{{ item }}"
  111. group: "{{ item }}"
  112. with_items:
  113. - root
  114. - "{{ ansible_ssh_user }}"
  115. # TODO: Update this file if the contents of the source file are not present in
  116. # the dest file, will need to make sure to ignore things that could be added
  117. - name: Copy the OpenShift admin client config(s)
  118. command: cp {{ openshift_master_config_dir }}/admin.kubeconfig ~{{ item }}/.kube/config
  119. args:
  120. creates: ~{{ item }}/.kube/config
  121. with_items:
  122. - root
  123. - "{{ ansible_ssh_user }}"
  124. - name: Update the permissions on the OpenShift admin client config(s)
  125. file:
  126. path: "~{{ item }}/.kube/config"
  127. state: file
  128. mode: 0700
  129. owner: "{{ item }}"
  130. group: "{{ item }}"
  131. with_items:
  132. - root
  133. - "{{ ansible_ssh_user }}"