diff options
| -rw-r--r-- | playbooks/common/openshift-master/config.yml | 8 | ||||
| -rw-r--r-- | playbooks/common/openshift-node/config.yml | 3 | ||||
| -rw-r--r-- | roles/flannel/README.md | 37 | ||||
| -rw-r--r-- | roles/flannel/defaults/main.yaml | 8 | ||||
| -rw-r--r-- | roles/flannel/handlers/main.yml | 8 | ||||
| -rw-r--r-- | roles/flannel/meta/main.yml | 16 | ||||
| -rw-r--r-- | roles/flannel/tasks/main.yml | 44 | ||||
| -rw-r--r-- | roles/flannel_register/README.md | 37 | ||||
| -rw-r--r-- | roles/flannel_register/defaults/main.yaml | 11 | ||||
| -rw-r--r-- | roles/flannel_register/meta/main.yml | 16 | ||||
| -rw-r--r-- | roles/flannel_register/tasks/main.yml | 14 | ||||
| -rw-r--r-- | roles/flannel_register/templates/flannel-config.json | 8 | ||||
| -rw-r--r-- | roles/openshift_common/tasks/main.yml | 1 | ||||
| -rwxr-xr-x | roles/openshift_facts/library/openshift_facts.py | 18 | ||||
| -rw-r--r-- | roles/openshift_master/tasks/main.yml | 11 | ||||
| -rw-r--r-- | roles/openshift_node/tasks/main.yml | 1 | 
16 files changed, 240 insertions, 1 deletions
diff --git a/playbooks/common/openshift-master/config.yml b/playbooks/common/openshift-master/config.yml index 1dec923fc..54d61da06 100644 --- a/playbooks/common/openshift-master/config.yml +++ b/playbooks/common/openshift-master/config.yml @@ -247,6 +247,14 @@      when: ( deployment_type in ['atomic-enterprise','openshift-enterprise'] ) and        (osm_use_cockpit | bool or osm_use_cockpit is undefined ) +- name: Configure flannel +  hosts: oo_first_master +  vars: +    etcd_urls: "{{ openshift.master.etcd_urls }}" +  roles: +  - role: flannel_register +    when: openshift.common.use_flannel | bool +  # Additional instance config for online deployments  - name: Additional instance config    hosts: oo_masters_deployment_type_online diff --git a/playbooks/common/openshift-node/config.yml b/playbooks/common/openshift-node/config.yml index a14ca8e11..e39e9164c 100644 --- a/playbooks/common/openshift-node/config.yml +++ b/playbooks/common/openshift-node/config.yml @@ -84,6 +84,7 @@    vars:      sync_tmpdir: "{{ hostvars.localhost.mktemp.stdout }}"      openshift_node_master_api_url: "{{ hostvars[groups.oo_first_master.0].openshift.master.api_url }}" +    etcd_urls: "{{ hostvars[groups.oo_first_master.0].openshift.master.etcd_urls }}"    pre_tasks:    - name: Ensure certificate directory exists      file: @@ -100,6 +101,8 @@      when: certs_missing    roles:    - openshift_node +  - role: flannel +    when: openshift.common.use_flannel | bool    - role: nickhammond.logrotate    - role: fluentd_node      when: openshift.common.use_fluentd | bool diff --git a/roles/flannel/README.md b/roles/flannel/README.md new file mode 100644 index 000000000..94cf15254 --- /dev/null +++ b/roles/flannel/README.md @@ -0,0 +1,37 @@ +Role Name +========= + +Configure flannel on openshift nodes + +Requirements +------------ + +This role assumes it's being deployed on a RHEL/Fedora based host with package +named 'flannel' available via yum, in version superior to 0.3. + +Role Variables +-------------- + +TODO + +Dependencies +------------ + +openshift_facts + +Example Playbook +---------------- + +    - hosts: openshift_node +      roles: +         - { flannel } + +License +------- + +Apache License, Version 2.0 + +Author Information +------------------ + +Sylvain Baubeau <sbaubeau@redhat.com> diff --git a/roles/flannel/defaults/main.yaml b/roles/flannel/defaults/main.yaml new file mode 100644 index 000000000..a9acab634 --- /dev/null +++ b/roles/flannel/defaults/main.yaml @@ -0,0 +1,8 @@ +--- +flannel_interface: "{{ ansible_default_ipv4.interface }}" +flannel_etcd_key: /openshift.com/network +etcd_hosts: "{{ etcd_urls }}" +etcd_conf_dir: "{{ openshift.common.config_base }}/node" +etcd_peer_ca_file: "{{ etcd_conf_dir }}/ca.crt" +etcd_peer_cert_file: "{{ etcd_conf_dir }}/system:node:{{ openshift.common.hostname }}.crt" +etcd_peer_key_file: "{{ etcd_conf_dir }}/system:node:{{ openshift.common.hostname }}.key" diff --git a/roles/flannel/handlers/main.yml b/roles/flannel/handlers/main.yml new file mode 100644 index 000000000..f9b9ae7f1 --- /dev/null +++ b/roles/flannel/handlers/main.yml @@ -0,0 +1,8 @@ +--- +- name: restart flanneld +  sudo: true +  service: name=flanneld state=restarted + +- name: restart docker +  sudo: true +  service: name=docker state=restarted diff --git a/roles/flannel/meta/main.yml b/roles/flannel/meta/main.yml new file mode 100644 index 000000000..a64934b3c --- /dev/null +++ b/roles/flannel/meta/main.yml @@ -0,0 +1,16 @@ +--- +galaxy_info: +  author: Sylvain +  description: etcd management +  company: Red Hat, Inc. +  license: Apache License, Version 2.0 +  min_ansible_version: 1.2 +  platforms: +  - name: EL +    versions: +    - 7 +  categories: +  - cloud +  - system +dependencies: +- { role: openshift_facts } diff --git a/roles/flannel/tasks/main.yml b/roles/flannel/tasks/main.yml new file mode 100644 index 000000000..8a871efb2 --- /dev/null +++ b/roles/flannel/tasks/main.yml @@ -0,0 +1,44 @@ +--- +- name: Install flannel +  sudo: true +  yum: pkg=flannel state=present + +- name: Set flannel etcd url +  sudo: true +  lineinfile: +    dest: /etc/sysconfig/flanneld +    backrefs: yes +    regexp: "^(FLANNEL_ETCD=)" +    line: '\1{{ etcd_hosts|join(",") }}' + +- name: Set flannel etcd key +  sudo: true +  lineinfile: +    dest: /etc/sysconfig/flanneld +    backrefs: yes +    regexp: "^(FLANNEL_ETCD_KEY=)" +    line: '\1{{ flannel_etcd_key }}' +  notify: + +- name: Set flannel options +  sudo: true +  lineinfile: +    dest: /etc/sysconfig/flanneld +    backrefs: yes +    regexp: "^#?(FLANNEL_OPTIONS=)" +    line: '\1--iface {{ flannel_interface }} --etcd-cafile={{ etcd_peer_ca_file }} --etcd-keyfile={{ etcd_peer_key_file }} --etcd-certfile={{ etcd_peer_cert_file }}' + +- name: Enable flanneld +  sudo: true +  service: +    name: flanneld +    state: started +    enabled: yes +  register: start_result + +- name: Remove docker bridge ip +  sudo: true +  shell: ip a del `ip a show docker0 | grep inet | awk '{print $2}'` dev docker0 +  notify: +    - restart docker +    - restart node diff --git a/roles/flannel_register/README.md b/roles/flannel_register/README.md new file mode 100644 index 000000000..a11c8fe53 --- /dev/null +++ b/roles/flannel_register/README.md @@ -0,0 +1,37 @@ +Role Name +========= + +Register flannel configuration into etcd + +Requirements +------------ + +This role assumes it's being deployed on a RHEL/Fedora based host with package +named 'flannel' available via yum, in version superior to 0.3. + +Role Variables +-------------- + +TODO + +Dependencies +------------ + +openshift_facts + +Example Playbook +---------------- + +    - hosts: openshift_master +      roles: +         - { flannel_register } + +License +------- + +Apache License, Version 2.0 + +Author Information +------------------ + +Sylvain Baubeau <sbaubeau@redhat.com> diff --git a/roles/flannel_register/defaults/main.yaml b/roles/flannel_register/defaults/main.yaml new file mode 100644 index 000000000..b7262b40f --- /dev/null +++ b/roles/flannel_register/defaults/main.yaml @@ -0,0 +1,11 @@ +--- +flannel_network: "{{ openshift.master.portal_net | default('172.16.1.1/16') }}" +flannel_min_network: "{{ min_network | default('172.16.5.0') }}" +flannel_subnet_len: "{{ subnet_len | default(24) }}" +flannel_etcd_key: /openshift.com/network +etcd_hosts: "{{ etcd_urls }}" +etcd_conf_dir: "{{ openshift.common.config_base }}/master" +etcd_peer_ca_file: "{{ etcd_conf_dir }}/ca.crt" +etcd_peer_cert_file: "{{ etcd_conf_dir }}/master.etcd-client.crt" +etcd_peer_key_file: "{{ etcd_conf_dir }}/master.etcd-client.key" + diff --git a/roles/flannel_register/meta/main.yml b/roles/flannel_register/meta/main.yml new file mode 100644 index 000000000..a64934b3c --- /dev/null +++ b/roles/flannel_register/meta/main.yml @@ -0,0 +1,16 @@ +--- +galaxy_info: +  author: Sylvain +  description: etcd management +  company: Red Hat, Inc. +  license: Apache License, Version 2.0 +  min_ansible_version: 1.2 +  platforms: +  - name: EL +    versions: +    - 7 +  categories: +  - cloud +  - system +dependencies: +- { role: openshift_facts } diff --git a/roles/flannel_register/tasks/main.yml b/roles/flannel_register/tasks/main.yml new file mode 100644 index 000000000..c58c74d34 --- /dev/null +++ b/roles/flannel_register/tasks/main.yml @@ -0,0 +1,14 @@ +--- +- name: Assures /etc/flannel dir exists +  sudo: true +  file: path=/etc/flannel state=directory + +- name: Generate etcd configuration for etcd +  sudo: true +  template: +    src: "flannel-config.json" +    dest: "/etc/flannel/config.json" + +- name: Insert flannel configuration into etcd +  sudo: true +  shell: 'curl -L --cacert "{{ etcd_peer_ca_file }}" --cert "{{ etcd_peer_cert_file }}" --key "{{ etcd_peer_key_file }}" "{{ etcd_hosts[0] }}/v2/keys{{ flannel_etcd_key }}/config" -XPUT --data-urlencode value@/etc/flannel/config.json' diff --git a/roles/flannel_register/templates/flannel-config.json b/roles/flannel_register/templates/flannel-config.json new file mode 100644 index 000000000..89ce4c30b --- /dev/null +++ b/roles/flannel_register/templates/flannel-config.json @@ -0,0 +1,8 @@ +{ +    "Network": "{{ flannel_network }}", +    "SubnetLen": {{ flannel_subnet_len }}, +    "SubnetMin": "{{ flannel_min_network }}", +    "Backend": { +        "Type": "host-gw" +     } +} diff --git a/roles/openshift_common/tasks/main.yml b/roles/openshift_common/tasks/main.yml index 73bd28630..64afc5081 100644 --- a/roles/openshift_common/tasks/main.yml +++ b/roles/openshift_common/tasks/main.yml @@ -13,6 +13,7 @@        sdn_network_plugin_name: "{{ os_sdn_network_plugin_name | default(None) }}"        deployment_type: "{{ openshift_deployment_type }}"        use_fluentd: "{{ openshift_use_fluentd | default(None) }}" +      use_flannel: "{{ openshift_use_flannel | default(None) }}"  - name: Set hostname    hostname: name={{ openshift.common.hostname }} diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py index 67994d11d..850dc8a69 100755 --- a/roles/openshift_facts/library/openshift_facts.py +++ b/roles/openshift_facts/library/openshift_facts.py @@ -306,6 +306,23 @@ def set_fluentd_facts_if_unset(facts):              facts['common']['use_fluentd'] = use_fluentd      return facts +def set_flannel_facts_if_unset(facts): +    """ Set flannel facts if not already present in facts dict +            dict: the facts dict updated with the flannel facts if +            missing +        Args: +            facts (dict): existing facts +        Returns: +            dict: the facts dict updated with the flannel +            facts if they were not already present + +    """ +    if 'common' in facts: +        if 'use_flannel' not in facts['common']: +            use_flannel = False +            facts['common']['use_flannel'] = use_flannel +    return facts +  def set_node_schedulability(facts):      """ Set schedulable facts if not already present in facts dict          Args: @@ -845,6 +862,7 @@ class OpenShiftFacts(object):          facts = set_url_facts_if_unset(facts)          facts = set_project_cfg_facts_if_unset(facts)          facts = set_fluentd_facts_if_unset(facts) +        facts = set_flannel_facts_if_unset(facts)          facts = set_node_schedulability(facts)          facts = set_master_selectors(facts)          facts = set_metrics_facts_if_unset(facts) diff --git a/roles/openshift_master/tasks/main.yml b/roles/openshift_master/tasks/main.yml index 94eb73346..da20d4f96 100644 --- a/roles/openshift_master/tasks/main.yml +++ b/roles/openshift_master/tasks/main.yml @@ -14,7 +14,10 @@  - name: Set master facts    openshift_facts: -    role: master +    role: "{{ item.role }}" +    local_facts: "{{ item.local_facts }}" +  with_items: +  - role: master      local_facts:        cluster_hostname: "{{ openshift_master_cluster_hostname | default(None) }}"        cluster_public_hostname: "{{ openshift_master_cluster_public_hostname | default(None) }}" @@ -62,6 +65,12 @@        api_server_args: "{{ osm_api_server_args | default(None) }}"        controller_args: "{{ osm_controller_args | default(None) }}"        infra_nodes: "{{ num_infra | default(None) }}" +  - role: common +    local_facts: +      hostname: "{{ openshift_hostname | default(none) }}" +      public_hostname: "{{ openshift_public_hostname | default(none) }}" +      deployment_type: "{{ openshift_deployment_type }}" +      use_flannel: "{{ openshift_use_flannel | default(None) }}"  - name: Install Master package    yum: pkg={{ openshift.common.service_type }}-master{{ openshift_version  }} state=present diff --git a/roles/openshift_node/tasks/main.yml b/roles/openshift_node/tasks/main.yml index 98271c8b3..cb92a8d4e 100644 --- a/roles/openshift_node/tasks/main.yml +++ b/roles/openshift_node/tasks/main.yml @@ -20,6 +20,7 @@        hostname: "{{ openshift_hostname | default(none) }}"        public_hostname: "{{ openshift_public_hostname | default(none) }}"        deployment_type: "{{ openshift_deployment_type }}" +      use_flannel: "{{ openshift_use_flannel | default(None) }}"    - role: node      local_facts:        labels: "{{ lookup('oo_option', 'openshift_node_labels') | default( openshift_node_labels | default(none), true) }}"  | 
