main.yml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. ---
  2. # TODO: actually have api_port, api_use_ssl, console_port, console_use_ssl,
  3. # etcd_use_ssl actually change the master config.
  4. - name: Set master OpenShift facts
  5. openshift_facts:
  6. role: 'master'
  7. local_facts:
  8. debug_level: "{{ openshift_master_debug_level | default(openshift.common.debug_level) }}"
  9. api_port: "{{ openshift_master_api_port | default(None) }}"
  10. api_url: "{{ openshift_master_api_url | default(None) }}"
  11. api_use_ssl: "{{ openshift_master_api_use_ssl | default(None) }}"
  12. public_api_url: "{{ openshift_master_public_api_url | default(None) }}"
  13. console_path: "{{ openshift_master_console_path | default(None) }}"
  14. console_port: "{{ openshift_master_console_port | default(None) }}"
  15. console_url: "{{ openshift_master_console_url | default(None) }}"
  16. console_use_ssl: "{{ openshift_master_console_use_ssl | default(None) }}"
  17. public_console_url: "{{ openshift_master_public_console_url | default(None) }}"
  18. etcd_port: "{{ openshift_master_etcd_port | default(None) }}"
  19. etcd_use_ssl: "{{ openshift_master_etcd_use_ssl | default(None) }}"
  20. portal_net: "{{ openshift_master_portal_net | default(None) }}"
  21. # TODO: These values need to be configurable
  22. - name: Set dns OpenShift facts
  23. openshift_facts:
  24. role: 'dns'
  25. local_facts:
  26. ip: "{{ openshift.common.ip }}"
  27. domain: local
  28. - name: Install OpenShift Master package
  29. yum: pkg=openshift-master state=installed
  30. register: install_result
  31. - name: Reload systemd units
  32. command: systemctl daemon-reload
  33. when: install_result | changed
  34. - name: Create certificate parent directory if it doesn't exist
  35. file:
  36. path: "{{ openshift_cert_parent_dir }}"
  37. state: directory
  38. - name: Create config parent directory if it doesn't exist
  39. file:
  40. path: "{{ openshift_master_config | dirname }}"
  41. state: directory
  42. # TODO: should probably use a template lookup for this
  43. # TODO: should allow for setting --etcd, --kubernetes options
  44. # TODO: recreate config if values change
  45. - name: Use enterprise default for oreg_url if not set
  46. set_fact:
  47. oreg_url: "openshift3_beta/ose-${component}:${version}"
  48. when: openshift.common.deployment_type == 'enterprise' and oreg_url is not defined
  49. - name: Use online default for oreg_url if not set
  50. set_fact:
  51. oreg_url: "docker-registry.ops.rhcloud.com/openshift3_beta/ose-${component}:${version}"
  52. when: openshift.common.deployment_type == 'online' and oreg_url is not defined
  53. - name: Create master config
  54. command: >
  55. /usr/bin/openshift start master --write-config
  56. --config={{ openshift_master_config }}
  57. --portal-net={{ openshift.master.portal_net }}
  58. --master={{ openshift.master.api_url }}
  59. --public-master={{ openshift.master.public_api_url }}
  60. --listen={{ 'https' if openshift.master.api_use_ssl else 'http' }}://0.0.0.0:{{ openshift.master.api_port }}
  61. {{ ('--images=' ~ oreg_url) if (oreg_url | default('', true) != '') else '' }}
  62. {{ ('--nodes=' ~ openshift_node_ips | join(',')) if (openshift_node_ips | default('', true) != '') else '' }}
  63. args:
  64. chdir: "{{ openshift_cert_parent_dir }}"
  65. creates: "{{ openshift_master_config }}"
  66. - name: Configure OpenShift settings
  67. lineinfile:
  68. dest: /etc/sysconfig/openshift-master
  69. regexp: '^OPTIONS='
  70. line: "OPTIONS=\"--config={{ openshift_master_config }} --loglevel={{ openshift.master.debug_level }}\""
  71. notify:
  72. - restart openshift-master
  73. - name: Start and enable openshift-master
  74. service: name=openshift-master enabled=yes state=started
  75. - name: Create the OpenShift client config dir(s)
  76. file:
  77. path: "~{{ item }}/.config/openshift"
  78. state: directory
  79. mode: 0700
  80. owner: "{{ item }}"
  81. group: "{{ item }}"
  82. with_items:
  83. - root
  84. - "{{ ansible_ssh_user }}"
  85. # TODO: Update this file if the contents of the source file are not present in
  86. # the dest file, will need to make sure to ignore things that could be added
  87. - name: Create the OpenShift client config(s)
  88. command: cp {{ openshift_cert_dir }}/openshift-client/.kubeconfig ~{{ item }}/.config/openshift/.config
  89. args:
  90. creates: ~{{ item }}/.config/openshift/.config
  91. with_items:
  92. - root
  93. - "{{ ansible_ssh_user }}"
  94. - name: Update the permissions on the OpenShift client config(s)
  95. file:
  96. path: "~{{ item }}/.config/openshift/.config"
  97. state: file
  98. mode: 0700
  99. owner: "{{ item }}"
  100. group: "{{ item }}"
  101. with_items:
  102. - root
  103. - "{{ ansible_ssh_user }}"