123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- ---
- # TODO: add validation for openshift_master_identity_providers
- # TODO: add ability to configure certificates given either a local file to
- # point to or certificate contents, set in default cert locations.
- - assert:
- that:
- - openshift_master_oauth_grant_method in openshift_master_valid_grant_methods
- when: openshift_master_oauth_grant_method is defined
- - fail:
- msg: "openshift_master_cluster_password must be set for multi-master installations"
- when: openshift_master_ha | bool and not openshift.master.cluster_defer_ha | bool and openshift_master_cluster_password is not defined
- - name: Set master facts
- openshift_facts:
- role: master
- local_facts:
- cluster_hostname: "{{ openshift_master_cluster_hostname | default(None) }}"
- cluster_public_hostname: "{{ openshift_master_cluster_public_hostname | default(None) }}"
- cluster_defer_ha: "{{ openshift_master_cluster_defer_ha | default(None) }}"
- debug_level: "{{ openshift_master_debug_level | default(openshift.common.debug_level) }}"
- api_port: "{{ openshift_master_api_port | default(None) }}"
- api_url: "{{ openshift_master_api_url | default(None) }}"
- api_use_ssl: "{{ openshift_master_api_use_ssl | default(None) }}"
- public_api_url: "{{ openshift_master_public_api_url | default(None) }}"
- console_path: "{{ openshift_master_console_path | default(None) }}"
- console_port: "{{ openshift_master_console_port | default(None) }}"
- console_url: "{{ openshift_master_console_url | default(None) }}"
- console_use_ssl: "{{ openshift_master_console_use_ssl | default(None) }}"
- public_console_url: "{{ openshift_master_public_console_url | default(None) }}"
- etcd_hosts: "{{ openshift_master_etcd_hosts | default(None)}}"
- etcd_port: "{{ openshift_master_etcd_port | default(None) }}"
- etcd_use_ssl: "{{ openshift_master_etcd_use_ssl | default(None) }}"
- etcd_urls: "{{ openshift_master_etcd_urls | default(None) }}"
- embedded_etcd: "{{ openshift_master_embedded_etcd | default(None) }}"
- embedded_kube: "{{ openshift_master_embedded_kube | default(None) }}"
- embedded_dns: "{{ openshift_master_embedded_dns | default(None) }}"
- dns_port: "{{ openshift_master_dns_port | default(None) }}"
- bind_addr: "{{ openshift_master_bind_addr | default(None) }}"
- portal_net: "{{ openshift_master_portal_net | default(None) }}"
- session_max_seconds: "{{ openshift_master_session_max_seconds | default(None) }}"
- session_name: "{{ openshift_master_session_name | default(None) }}"
- session_secrets_file: "{{ openshift_master_session_secrets_file | default(None) }}"
- access_token_max_seconds: "{{ openshift_master_access_token_max_seconds | default(None) }}"
- auth_token_max_seconds: "{{ openshift_master_auth_token_max_seconds | default(None) }}"
- identity_providers: "{{ openshift_master_identity_providers | default(None) }}"
- registry_url: "{{ oreg_url | default(None) }}"
- oauth_grant_method: "{{ openshift_master_oauth_grant_method | default(None) }}"
- sdn_cluster_network_cidr: "{{ osm_cluster_network_cidr | default(None) }}"
- sdn_host_subnet_length: "{{ osm_host_subnet_length | default(None) }}"
- default_subdomain: "{{ osm_default_subdomain | default(None) }}"
- custom_cors_origins: "{{ osm_custom_cors_origins | default(None) }}"
- default_node_selector: "{{ osm_default_node_selector | default(None) }}"
- api_server_args: "{{ osm_api_server_args | default(None) }}"
- controller_args: "{{ osm_controller_args | default(None) }}"
- - name: Install Master package
- yum: pkg={{ openshift.common.service_type }}-master state=present
- register: install_result
- - name: Check for RPM generated config marker file /etc/origin/.config_managed
- stat: path=/etc/origin/.rpmgenerated
- register: rpmgenerated_config
- - name: Remove RPM generated config files
- file:
- path: "{{ item }}"
- state: absent
- when: openshift.common.service_type in ['atomic-enterprise','openshift-enterprise'] and rpmgenerated_config.stat.exists == true
- with_items:
- - "{{ openshift.common.config_base }}/master"
- - "{{ openshift.common.config_base }}/node"
- - "{{ openshift.common.config_base }}/.rpmgenerated"
- # TODO: These values need to be configurable
- - name: Set dns facts
- openshift_facts:
- role: dns
- local_facts:
- ip: "{{ openshift_master_cluster_vip | default(openshift.common.ip, true) | default(None) }}"
- domain: cluster.local
- when: openshift.master.embedded_dns
- - name: Create config parent directory if it doesn't exist
- file:
- path: "{{ openshift_master_config_dir }}"
- state: directory
- - name: Create the policy file if it does not already exist
- command: >
- {{ openshift.common.admin_binary }} create-bootstrap-policy-file
- --filename={{ openshift_master_policy }}
- args:
- creates: "{{ openshift_master_policy }}"
- notify:
- - restart master
- - name: Create the scheduler config
- template:
- dest: "{{ openshift_master_scheduler_conf }}"
- src: scheduler.json.j2
- notify:
- - restart master
- - name: Install httpd-tools if needed
- yum: pkg=httpd-tools state=present
- when: item.kind == 'HTPasswdPasswordIdentityProvider'
- with_items: openshift.master.identity_providers
- - name: Ensure htpasswd directory exists
- file:
- path: "{{ item.filename | dirname }}"
- state: directory
- when: item.kind == 'HTPasswdPasswordIdentityProvider'
- with_items: openshift.master.identity_providers
- - name: Create the htpasswd file if needed
- copy:
- dest: "{{ item.filename }}"
- content: ""
- mode: 0600
- force: no
- when: item.kind == 'HTPasswdPasswordIdentityProvider'
- with_items: openshift.master.identity_providers
- # TODO: add the validate parameter when there is a validation command to run
- - name: Create master config
- template:
- dest: "{{ openshift_master_config_file }}"
- src: master.yaml.v1.j2
- notify:
- - restart master
- - name: Configure master settings
- lineinfile:
- dest: /etc/sysconfig/{{ openshift.common.service_type }}-master
- regexp: "{{ item.regex }}"
- line: "{{ item.line }}"
- with_items:
- - regex: '^OPTIONS='
- line: "OPTIONS=--loglevel={{ openshift.master.debug_level }}"
- - regex: '^CONFIG_FILE='
- line: "CONFIG_FILE={{ openshift_master_config_file }}"
- notify:
- - restart master
- - name: Start and enable master
- service: name={{ openshift.common.service_type }}-master enabled=yes state=started
- when: not openshift_master_ha | bool
- register: start_result
- - name: pause to prevent service restart from interfering with bootstrapping
- pause: seconds=30
- when: start_result | changed
- - name: Install cluster packages
- yum: pkg=pcs state=present
- when: openshift_master_ha | bool and not openshift.master.cluster_defer_ha | bool
- register: install_result
- - name: Start and enable cluster service
- service: name=pcsd enabled=yes state=started
- when: openshift_master_ha | bool and not openshift.master.cluster_defer_ha | bool
- - name: Set the cluster user password
- shell: echo {{ openshift_master_cluster_password | quote }} | passwd --stdin hacluster
- when: install_result | changed
- - name: Create the client config dir(s)
- file:
- path: "~{{ item }}/.kube"
- state: directory
- mode: 0700
- owner: "{{ item }}"
- group: "{{ item }}"
- with_items:
- - root
- - "{{ ansible_ssh_user }}"
- # TODO: Update this file if the contents of the source file are not present in
- # the dest file, will need to make sure to ignore things that could be added
- - name: Copy the admin client config(s)
- command: cp {{ openshift_master_config_dir }}/admin.kubeconfig ~{{ item }}/.kube/config
- args:
- creates: ~{{ item }}/.kube/config
- with_items:
- - root
- - "{{ ansible_ssh_user }}"
- - name: Update the permissions on the admin client config(s)
- file:
- path: "~{{ item }}/.kube/config"
- state: file
- mode: 0700
- owner: "{{ item }}"
- group: "{{ item }}"
- with_items:
- - root
- - "{{ ansible_ssh_user }}"
|