diff options
31 files changed, 469 insertions, 107 deletions
diff --git a/README_CONTAINERIZED_INSTALLATION.md b/README_CONTAINERIZED_INSTALLATION.md index c615154ef..0a0ebb836 100644 --- a/README_CONTAINERIZED_INSTALLATION.md +++ b/README_CONTAINERIZED_INSTALLATION.md @@ -31,7 +31,7 @@ native clients.  The wrapper scripts mount a limited subset of paths, _~/.kube_, _/etc/origin/_,  and _/tmp_. Be mindful of this when passing in files to be processed by `oc` or   `oadm`. You may find it easier to redirect input like this : -  +   `oc create -f - < my_file.json`  ## Technical Notes @@ -48,18 +48,18 @@ before attempting to pull any of the following images.          openshift/origin          openshift/node (node + openshift-sdn + openvswitch rpm for client tools)          openshift/openvswitch (centos7 + openvswitch rpm, runs ovsdb ovsctl processes) -        registry.access.redhat.com/rhel7/etcd +        registry.access.redhat.com/rhel7/etcd3      OpenShift Enterprise          openshift3/ose          openshift3/node          openshift3/openvswitch -        registry.access.redhat.com/rhel7/etcd +        registry.access.redhat.com/rhel7/etcd3      Atomic Enterprise Platform          aep3/aep          aep3/node          aep3/openvswitch -        registry.access.redhat.com/rhel7/etcd -         +        registry.access.redhat.com/rhel7/etcd3 +    * note openshift3/* and aep3/* images come from registry.access.redhat.com and  rely on the --additional-repository flag being set appropriately. diff --git a/filter_plugins/oo_filters.py b/filter_plugins/oo_filters.py index 93fdd5ae4..97eacf9bf 100644 --- a/filter_plugins/oo_filters.py +++ b/filter_plugins/oo_filters.py @@ -889,11 +889,32 @@ class FilterModule(object):                                            'servers': FilterModule.oo_haproxy_backend_masters(servers_hostvars, nuage_rest_port)})          return loadbalancer_backends +    @staticmethod +    def oo_chomp_commit_offset(version): +        """Chomp any "+git.foo" commit offset string from the given `version` +        and return the modified version string. + +    Ex: +    - chomp_commit_offset(None)                 => None +    - chomp_commit_offset(1337)                 => "1337" +    - chomp_commit_offset("v3.4.0.15+git.derp") => "v3.4.0.15" +    - chomp_commit_offset("v3.4.0.15")          => "v3.4.0.15" +    - chomp_commit_offset("v1.3.0+52492b4")     => "v1.3.0" +        """ +        if version is None: +            return version +        else: +            # Stringify, just in case it's a Number type. Split by '+' and +            # return the first split. No concerns about strings without a +            # '+', .split() returns an array of the original string. +            return str(version).split('+')[0] +      def filters(self):          """ returns a mapping of filters to methods """          return {              "oo_select_keys": self.oo_select_keys,              "oo_select_keys_from_list": self.oo_select_keys_from_list, +            "oo_chomp_commit_offset": self.oo_chomp_commit_offset,              "oo_collect": self.oo_collect,              "oo_flatten": self.oo_flatten,              "oo_pdb": self.oo_pdb, diff --git a/playbooks/adhoc/uninstall.yml b/playbooks/adhoc/uninstall.yml index 789f66b14..4ea639cbe 100644 --- a/playbooks/adhoc/uninstall.yml +++ b/playbooks/adhoc/uninstall.yml @@ -338,6 +338,7 @@      failed_when: False      with_items:      - etcd +    - etcd3      - firewalld    - name: Stop additional atomic services @@ -352,6 +353,7 @@      when: not is_atomic | bool      with_items:      - etcd +    - etcd3    - shell: systemctl reset-failed      changed_when: False @@ -365,6 +367,7 @@      - /etc/ansible/facts.d/openshift.fact      - /etc/etcd      - /etc/systemd/system/etcd_container.service +    - /etc/profile.d/etcdctl.sh    # Intenationally using rm command over file module because if someone had mounted a filesystem    # at /var/lib/etcd then the contents was not removed correctly diff --git a/playbooks/byo/openshift-cluster/upgrades/upgrade_etcd.yml b/playbooks/byo/openshift-cluster/upgrades/upgrade_etcd.yml new file mode 100644 index 000000000..c25f96212 --- /dev/null +++ b/playbooks/byo/openshift-cluster/upgrades/upgrade_etcd.yml @@ -0,0 +1,26 @@ +--- +- include: ../../../common/openshift-cluster/verify_ansible_version.yml + +- name: Create initial host groups for localhost +  hosts: localhost +  connection: local +  become: no +  gather_facts: no +  tags: +  - always +  tasks: +  - include_vars: ../cluster_hosts.yml +  - add_host: +      name: "{{ item }}" +      groups: l_oo_all_hosts +    with_items: "{{ g_all_hosts | default([]) }}" + +- name: Create initial host groups for all hosts +  hosts: l_oo_all_hosts +  gather_facts: no +  tags: +  - always +  tasks: +  - include_vars: ../cluster_hosts.yml + +- include: ../../../common/openshift-cluster/upgrades/etcd/main.yml diff --git a/playbooks/common/openshift-cluster/upgrades/etcd/backup.yml b/playbooks/common/openshift-cluster/upgrades/etcd/backup.yml new file mode 100644 index 000000000..57b156b1c --- /dev/null +++ b/playbooks/common/openshift-cluster/upgrades/etcd/backup.yml @@ -0,0 +1,73 @@ +- name: Backup etcd +  hosts: etcd_hosts_to_backup +  vars: +    embedded_etcd: "{{ hostvars[groups.oo_first_master.0].openshift.master.embedded_etcd }}" +    timestamp: "{{ lookup('pipe', 'date +%Y%m%d%H%M%S') }}" +  roles: +  - openshift_facts +  tasks: +  # Ensure we persist the etcd role for this host in openshift_facts +  - openshift_facts: +      role: etcd +      local_facts: {} +    when: "'etcd' not in openshift" + +  - stat: path=/var/lib/openshift +    register: var_lib_openshift + +  - stat: path=/var/lib/origin +    register: var_lib_origin + +  - name: Create origin symlink if necessary +    file: src=/var/lib/openshift/ dest=/var/lib/origin state=link +    when: var_lib_openshift.stat.exists == True and var_lib_origin.stat.exists == False + +  # TODO: replace shell module with command and update later checks +  # We assume to be using the data dir for all backups. +  - name: Check available disk space for etcd backup +    shell: df --output=avail -k {{ openshift.common.data_dir }} | tail -n 1 +    register: avail_disk + +  # TODO: replace shell module with command and update later checks +  - name: Check current embedded etcd disk usage +    shell: du -k {{ openshift.etcd.etcd_data_dir }} | tail -n 1 | cut -f1 +    register: etcd_disk_usage +    when: embedded_etcd | bool + +  - name: Abort if insufficient disk space for etcd backup +    fail: +      msg: > +        {{ etcd_disk_usage.stdout }} Kb disk space required for etcd backup, +        {{ avail_disk.stdout }} Kb available. +    when: (embedded_etcd | bool) and (etcd_disk_usage.stdout|int > avail_disk.stdout|int) + +  - name: Install etcd (for etcdctl) +    action: "{{ ansible_pkg_mgr }} name=etcd state=present" +    when: not openshift.common.is_atomic | bool + +  - name: Generate etcd backup +    command: > +      etcdctl backup --data-dir={{ openshift.etcd.etcd_data_dir }} +      --backup-dir={{ openshift.common.data_dir }}/etcd-backup-{{ backup_tag | default('') }}{{ timestamp }} + +  - set_fact: +      etcd_backup_complete: True + +  - name: Display location of etcd backup +    debug: +      msg: "Etcd backup created in {{ openshift.common.data_dir }}/etcd-backup-{{ backup_tag | default('') }}{{ timestamp }}" + +- name: Gate on etcd backup +  hosts: localhost +  connection: local +  become: no +  tasks: +  - set_fact: +      etcd_backup_completed: "{{ hostvars +                                 | oo_select_keys(groups.etcd_hosts_to_backup) +                                 | oo_collect('inventory_hostname', {'etcd_backup_complete': true}) }}" +  - set_fact: +      etcd_backup_failed: "{{ groups.etcd_hosts_to_backup | difference(etcd_backup_completed) }}" +  - fail: +      msg: "Upgrade cannot continue. The following hosts did not complete etcd backup: {{ etcd_backup_failed | join(',') }}" +    when: etcd_backup_failed | length > 0 diff --git a/playbooks/common/openshift-cluster/upgrades/etcd/containerized_tasks.yml b/playbooks/common/openshift-cluster/upgrades/etcd/containerized_tasks.yml new file mode 100644 index 000000000..35f391f8c --- /dev/null +++ b/playbooks/common/openshift-cluster/upgrades/etcd/containerized_tasks.yml @@ -0,0 +1,47 @@ +--- +- name: Verify cluster is healthy pre-upgrade +  command: "etcdctl --cert-file /etc/etcd/peer.crt --key-file /etc/etcd/peer.key --ca-file /etc/etcd/ca.crt -C https://{{ openshift.common.hostname }}:2379 cluster-health" + +- name: Get current image +  shell: grep 'ExecStart=' /etc/systemd/system/etcd_container.service | awk '{print $NF}' +  register: current_image + +- name: Set new_etcd_image +  set_fact: +    new_etcd_image: "{{ current_image.stdout | regex_replace('/etcd.*$','/etcd3:' ~ upgrade_version ) if upgrade_version | version_compare('3.0','>=') +                        else current_image.stdout.split(':')[0] ~ ':' ~ upgrade_version }}" + +- name: Pull new etcd image +  command: "docker pull {{ new_etcd_image }}" + +- name: Update to latest etcd image +  replace: +    dest: /etc/systemd/system/etcd_container.service +    regexp: "{{ current_image.stdout }}$" +    replace: "{{ new_etcd_image }}" + +- name: Restart etcd_container +  systemd: +    name: etcd_container +    daemon_reload: yes +    state: restarted + +## TODO: probably should just move this into the backup playbooks, also this +## will fail on atomic host. We need to revisit how to do etcd backups there as +## the container may be newer than etcdctl on the host. Assumes etcd3 obsoletes etcd (7.3.1) +- name: Upgrade etcd for etcdctl when not atomic +  action: "{{ ansible_pkg_mgr }} name=etcd ensure=latest" +  when: not openshift.common.is_atomic | bool + +- name: Verify cluster is healthy +  command: "etcdctl --cert-file /etc/etcd/peer.crt --key-file /etc/etcd/peer.key --ca-file /etc/etcd/ca.crt -C https://{{ openshift.common.hostname }}:2379 cluster-health" +  register: etcdctl +  until: etcdctl.rc == 0 +  retries: 3 +  delay: 10 + +- name: Store new etcd_image +  openshift_facts: +    role: etcd +    local_facts: +      etcd_image: "{{ new_etcd_image }}" diff --git a/playbooks/common/openshift-cluster/upgrades/etcd/fedora_tasks.yml b/playbooks/common/openshift-cluster/upgrades/etcd/fedora_tasks.yml new file mode 100644 index 000000000..30232110e --- /dev/null +++ b/playbooks/common/openshift-cluster/upgrades/etcd/fedora_tasks.yml @@ -0,0 +1,23 @@ +--- +# F23 GA'd with etcd 2.0, currently has 2.2 in updates +# F24 GA'd with etcd-2.2, currently has 2.2 in updates +# F25 Beta currently has etcd 3.0 +- name: Verify cluster is healthy pre-upgrade +  command: "etcdctl --cert-file /etc/etcd/peer.crt --key-file /etc/etcd/peer.key --ca-file /etc/etcd/ca.crt -C https://{{ openshift.common.hostname }}:2379 cluster-health" + +- name: Update etcd +  package: +    name: "etcd" +    state: "latest" + +- name: Restart etcd +  service: +    name: etcd +    state: restarted + +- name: Verify cluster is healthy +  command: "etcdctl --cert-file /etc/etcd/peer.crt --key-file /etc/etcd/peer.key --ca-file /etc/etcd/ca.crt -C https://{{ openshift.common.hostname }}:2379 cluster-health" +  register: etcdctl +  until: etcdctl.rc == 0 +  retries: 3 +  delay: 10 diff --git a/playbooks/common/openshift-cluster/upgrades/etcd/files/etcdctl.sh b/playbooks/common/openshift-cluster/upgrades/etcd/files/etcdctl.sh new file mode 120000 index 000000000..641e04e44 --- /dev/null +++ b/playbooks/common/openshift-cluster/upgrades/etcd/files/etcdctl.sh @@ -0,0 +1 @@ +../roles/etcd/files/etcdctl.sh
\ No newline at end of file diff --git a/playbooks/common/openshift-cluster/upgrades/etcd/filter_plugins b/playbooks/common/openshift-cluster/upgrades/etcd/filter_plugins new file mode 120000 index 000000000..27ddaa18b --- /dev/null +++ b/playbooks/common/openshift-cluster/upgrades/etcd/filter_plugins @@ -0,0 +1 @@ +../../../../../filter_plugins
\ No newline at end of file diff --git a/playbooks/common/openshift-cluster/upgrades/etcd/lookup_plugins b/playbooks/common/openshift-cluster/upgrades/etcd/lookup_plugins new file mode 120000 index 000000000..cf407f69b --- /dev/null +++ b/playbooks/common/openshift-cluster/upgrades/etcd/lookup_plugins @@ -0,0 +1 @@ +../../../../../lookup_plugins
\ No newline at end of file diff --git a/playbooks/common/openshift-cluster/upgrades/etcd/main.yml b/playbooks/common/openshift-cluster/upgrades/etcd/main.yml new file mode 100644 index 000000000..cce844403 --- /dev/null +++ b/playbooks/common/openshift-cluster/upgrades/etcd/main.yml @@ -0,0 +1,122 @@ +--- +# For 1.4/3.4 we want to upgrade everyone to etcd-3.0. etcd docs say to +# upgrade from 2.0.x to 2.1.x to 2.2.x to 2.3.x to 3.0.x. While this is a tedius +# task for RHEL and CENTOS it's simply not possible in Fedora unless you've +# mirrored packages on your own because only the GA and latest versions are +# available in the repos. So for Fedora we'll simply skip this, sorry. + +- include: ../../evaluate_groups.yml +  tags: +  - always + +- name: Evaluate additional groups for upgrade +  hosts: localhost +  connection: local +  become: no +  tasks: +  - name: Evaluate etcd_hosts_to_upgrade +    add_host: +      name: "{{ item }}" +      groups: etcd_hosts_to_upgrade, etcd_hosts_to_backup +    with_items: "{{ groups.oo_etcd_to_config if groups.oo_etcd_to_config is defined and groups.oo_etcd_to_config | length > 0 else groups.oo_first_master }}" + +- name: Backup etcd before upgrading anything +  include: backup.yml +  vars: +    backup_tag: "pre-upgrade-" + +- name: Drop etcdctl profiles +  hosts: etcd_hosts_to_upgrade +  tasks: +  - include: roles/etcd/tasks/etcdctl.yml + +- name: Determine etcd version +  hosts: etcd_hosts_to_upgrade +  tasks: +  - name: Record RPM based etcd version +    command: rpm -qa --qf '%{version}' etcd\* +    register: etcd_installed_version +    failed_when: false +    when: not openshift.common.is_containerized | bool +  - name: Record containerized etcd version +    command: docker exec etcd_container rpm -qa --qf '%{version}' etcd\* +    register: etcd_installed_version +    failed_when: false +    when: openshift.common.is_containerized | bool + +# I really dislike this copy/pasta but I wasn't able to find a way to get it to loop +# through hosts, then loop through tasks only when appropriate +- name: Upgrade to 2.1 +  hosts: etcd_hosts_to_upgrade +  serial: 1 +  vars: +    upgrade_version: '2.1' +  tasks: +  - include: rhel_tasks.yml +    when: etcd_installed_version.stdout | default('99') | version_compare('2.1','<') and ansible_distribution == 'RedHat' and not openshift.common.is_containerized | bool + +- name: Upgrade RPM hosts to 2.2 +  hosts: etcd_hosts_to_upgrade +  serial: 1 +  vars: +    upgrade_version: '2.2' +  tasks: +  - include: rhel_tasks.yml +    when: etcd_installed_version.stdout | default('99') | version_compare('2.2','<') and ansible_distribution == 'RedHat' and not openshift.common.is_containerized | bool + +- name: Upgrade containerized hosts to 2.2.5 +  hosts: etcd_hosts_to_upgrade +  serial: 1 +  vars: +    upgrade_version: 2.2.5 +  tasks: +  - include: containerized_tasks.yml +    when: etcd_installed_version.stdout | default('99') | version_compare('2.2','<') and openshift.common.is_containerized | bool + +- name: Upgrade RPM hosts to 2.3 +  hosts: etcd_hosts_to_upgrade +  serial: 1 +  vars: +    upgrade_version: '2.3' +  tasks: +  - include: rhel_tasks.yml +    when: etcd_installed_version.stdout | default('99') | version_compare('2.3','<') and ansible_distribution == 'RedHat' and not openshift.common.is_containerized | bool + +- name: Upgrade containerized hosts to 2.3.7 +  hosts: etcd_hosts_to_upgrade +  serial: 1 +  vars: +    upgrade_version: 2.3.7 +  tasks: +  - include: containerized_tasks.yml +    when: etcd_installed_version.stdout | default('99') | version_compare('2.3','<') and openshift.common.is_containerized | bool + +- name: Upgrade RPM hosts to 3.0 +  hosts: etcd_hosts_to_upgrade +  serial: 1 +  vars: +    upgrade_version: '3.0' +  tasks: +  - include: rhel_tasks.yml +    when: etcd_installed_version.stdout | default('99') | version_compare('3.0','<') and ansible_distribution == 'RedHat' and not openshift.common.is_containerized | bool + +- name: Upgrade containerized hosts to etcd3 image +  hosts: etcd_hosts_to_upgrade +  serial: 1 +  vars: +    upgrade_version: 3.0.3 +  tasks: +  - include: containerized_tasks.yml +    when: etcd_installed_version.stdout | default('99') | version_compare('3.0','<') and openshift.common.is_containerized | bool + +- name: Upgrade fedora to latest +  hosts: etcd_hosts_to_upgrade +  serial: 1 +  tasks: +  - include: fedora_tasks.yml +    when: ansible_distribution == 'Fedora' and not openshift.common.is_containerized | bool + +- name: Backup etcd +  include: backup.yml +  vars: +    backup_tag: "post-3.0-" diff --git a/playbooks/common/openshift-cluster/upgrades/etcd/rhel_tasks.yml b/playbooks/common/openshift-cluster/upgrades/etcd/rhel_tasks.yml new file mode 100644 index 000000000..8e7dc9d9b --- /dev/null +++ b/playbooks/common/openshift-cluster/upgrades/etcd/rhel_tasks.yml @@ -0,0 +1,23 @@ +--- +- name: Verify cluster is healthy pre-upgrade +  command: "etcdctl --cert-file /etc/etcd/peer.crt --key-file /etc/etcd/peer.key --ca-file /etc/etcd/ca.crt -C https://{{ openshift.common.hostname }}:2379 cluster-health" + +- name: Update etcd package but exclude etcd3 +  command: "{{ ansible_pkg_mgr }} install -y etcd-{{ upgrade_version }}\\* --exclude etcd3" +  when: upgrade_version | version_compare('3.0','<') + +- name: Update etcd package not excluding etcd3 +  command: "{{ ansible_pkg_mgr }} install -y etcd3-{{ upgrade_version }}\\*" +  when: not upgrade_version | version_compare('3.0','<') + +- name: Restart etcd +  service: +    name: etcd +    state: restarted + +- name: Verify cluster is healthy +  command: "etcdctl --cert-file /etc/etcd/peer.crt --key-file /etc/etcd/peer.key --ca-file /etc/etcd/ca.crt -C https://{{ openshift.common.hostname }}:2379 cluster-health" +  register: etcdctl +  until: etcdctl.rc == 0 +  retries: 3 +  delay: 10 diff --git a/playbooks/common/openshift-cluster/upgrades/etcd/roles b/playbooks/common/openshift-cluster/upgrades/etcd/roles new file mode 120000 index 000000000..6bc1a7aef --- /dev/null +++ b/playbooks/common/openshift-cluster/upgrades/etcd/roles @@ -0,0 +1 @@ +../../../../../roles
\ No newline at end of file diff --git a/playbooks/common/openshift-cluster/upgrades/upgrade_control_plane.yml b/playbooks/common/openshift-cluster/upgrades/upgrade_control_plane.yml index 764563d28..57c25aa41 100644 --- a/playbooks/common/openshift-cluster/upgrades/upgrade_control_plane.yml +++ b/playbooks/common/openshift-cluster/upgrades/upgrade_control_plane.yml @@ -25,81 +25,10 @@        role: master        local_facts:          embedded_etcd: "{{ groups.oo_etcd_to_config | default([]) | length == 0 }}" +        debug_level: "{{ openshift_master_debug_level | default(openshift.common.debug_level | default(2)) }}"  - name: Backup etcd -  hosts: etcd_hosts_to_backup -  vars: -    embedded_etcd: "{{ groups.oo_etcd_to_config | default([]) | length == 0 }}" -    timestamp: "{{ lookup('pipe', 'date +%Y%m%d%H%M%S') }}" -  roles: -  - openshift_facts -  tasks: -  # Ensure we persist the etcd role for this host in openshift_facts -  - openshift_facts: -      role: etcd -      local_facts: {} -    when: "'etcd' not in openshift" - -  - stat: path=/var/lib/openshift -    register: var_lib_openshift - -  - stat: path=/var/lib/origin -    register: var_lib_origin - -  - name: Create origin symlink if necessary -    file: src=/var/lib/openshift/ dest=/var/lib/origin state=link -    when: var_lib_openshift.stat.exists == True and var_lib_origin.stat.exists == False - -  # TODO: replace shell module with command and update later checks -  # We assume to be using the data dir for all backups. -  - name: Check available disk space for etcd backup -    shell: df --output=avail -k {{ openshift.common.data_dir }} | tail -n 1 -    register: avail_disk - -  # TODO: replace shell module with command and update later checks -  - name: Check current embedded etcd disk usage -    shell: du -k {{ openshift.etcd.etcd_data_dir }} | tail -n 1 | cut -f1 -    register: etcd_disk_usage -    when: embedded_etcd | bool - -  - name: Abort if insufficient disk space for etcd backup -    fail: -      msg: > -        {{ etcd_disk_usage.stdout }} Kb disk space required for etcd backup, -        {{ avail_disk.stdout }} Kb available. -    when: (embedded_etcd | bool) and (etcd_disk_usage.stdout|int > avail_disk.stdout|int) - -  - name: Install etcd (for etcdctl) -    action: "{{ ansible_pkg_mgr }} name=etcd state=installed" -    when: not openshift.common.is_atomic | bool - -  - name: Generate etcd backup -    command: > -      etcdctl backup --data-dir={{ openshift.etcd.etcd_data_dir }} -      --backup-dir={{ openshift.common.data_dir }}/etcd-backup-{{ timestamp }} - -  - set_fact: -      etcd_backup_complete: True - -  - name: Display location of etcd backup -    debug: -      msg: "Etcd backup created in {{ openshift.common.data_dir }}/etcd-backup-{{ timestamp }}" - - -- name: Gate on etcd backup -  hosts: localhost -  connection: local -  become: no -  tasks: -  - set_fact: -      etcd_backup_completed: "{{ hostvars -                                 | oo_select_keys(groups.etcd_hosts_to_backup) -                                 | oo_collect('inventory_hostname', {'etcd_backup_complete': true}) }}" -  - set_fact: -      etcd_backup_failed: "{{ groups.etcd_hosts_to_backup | difference(etcd_backup_completed) }}" -  - fail: -      msg: "Upgrade cannot continue. The following hosts did not complete etcd backup: {{ etcd_backup_failed | join(',') }}" -    when: etcd_backup_failed | length > 0 +  include: ./etcd/backup.yml  - name: Upgrade master packages    hosts: oo_masters_to_config diff --git a/playbooks/common/openshift-master/config.yml b/playbooks/common/openshift-master/config.yml index a53c55c14..5fcb850a2 100644 --- a/playbooks/common/openshift-master/config.yml +++ b/playbooks/common/openshift-master/config.yml @@ -53,7 +53,7 @@      when: openshift_hosted_metrics_deployer_prefix is not defined    - set_fact:        openshift_hosted_metrics_deployer_version: "{{ lookup('oo_option', 'openshift_hosted_metrics_deployer_version') | default('latest') }}" -    when: openshift_hosted_metrics_deployer_prefix is not defined +    when: openshift_hosted_metrics_deployer_version is not defined    roles:    - openshift_facts    post_tasks: diff --git a/roles/docker/README.md b/roles/docker/README.md index 6b5ee4421..1f0d94da0 100644 --- a/roles/docker/README.md +++ b/roles/docker/README.md @@ -17,7 +17,7 @@ docker_udev_workaround: raises udevd timeout to 5 minutes (https://bugzilla.redh  Dependencies  ------------ -None +Depends on the os_firewall role.  Example Playbook  ---------------- diff --git a/roles/docker/meta/main.yml b/roles/docker/meta/main.yml index 6e2c98601..3d362158d 100644 --- a/roles/docker/meta/main.yml +++ b/roles/docker/meta/main.yml @@ -9,4 +9,6 @@ galaxy_info:    - name: EL      versions:      - 7 -dependencies: [] +dependencies: +  - role: os_firewall +    os_firewall_use_firewalld: False diff --git a/roles/docker/tasks/main.yml b/roles/docker/tasks/main.yml index 240673b22..9b7ef0830 100644 --- a/roles/docker/tasks/main.yml +++ b/roles/docker/tasks/main.yml @@ -1,7 +1,4 @@  --- -- stat: path=/etc/sysconfig/docker-storage -  register: docker_storage_check -  - name: Get current installed Docker version    command: "{{ repoquery_cmd }} --installed --qf '%{version}' docker"    when: not openshift.common.is_atomic | bool @@ -57,17 +54,6 @@      dest: "{{ docker_systemd_dir }}/custom.conf"      src: custom.conf.j2 -- name: Start the Docker service -  systemd: -    name: docker -    enabled: yes -    state: started -    daemon_reload: yes -  register: start_result - -- set_fact: -    docker_service_status_changed: start_result | changed -  - include: udev_workaround.yml    when: docker_udev_workaround | default(False) | bool @@ -125,4 +111,15 @@    notify:      - restart docker +- name: Start the Docker service +  systemd: +    name: docker +    enabled: yes +    state: started +    daemon_reload: yes +  register: start_result + +- set_fact: +    docker_service_status_changed: start_result | changed +  - meta: flush_handlers diff --git a/roles/etcd/etcdctl.sh b/roles/etcd/etcdctl.sh new file mode 100644 index 000000000..0e324a8a9 --- /dev/null +++ b/roles/etcd/etcdctl.sh @@ -0,0 +1,11 @@ +#!/bin/bash +# Sets up handy aliases for etcd, need etcdctl2 and etcdctl3 because +# command flags are different between the two. Should work on stand +# alone etcd hosts and master + etcd hosts too because we use the peer keys. +etcdctl2() { + /usr/bin/etcdctl --cert-file /etc/etcd/peer.crt --key-file /etc/etcd/peer.key --ca-file /etc/etcd/ca.crt -C https://`hostname`:2379 ${@} +} + +etcdctl3() { + ETCDCTL_API=3 /usr/bin/etcdctl --cert /etc/etcd/peer.crt --key /etc/etcd/peer.key --cacert /etc/etcd/ca.crt --endpoints https://`hostname`:2379 ${@} +} diff --git a/roles/etcd/files/etcdctl.sh b/roles/etcd/files/etcdctl.sh new file mode 100644 index 000000000..0e324a8a9 --- /dev/null +++ b/roles/etcd/files/etcdctl.sh @@ -0,0 +1,11 @@ +#!/bin/bash +# Sets up handy aliases for etcd, need etcdctl2 and etcdctl3 because +# command flags are different between the two. Should work on stand +# alone etcd hosts and master + etcd hosts too because we use the peer keys. +etcdctl2() { + /usr/bin/etcdctl --cert-file /etc/etcd/peer.crt --key-file /etc/etcd/peer.key --ca-file /etc/etcd/ca.crt -C https://`hostname`:2379 ${@} +} + +etcdctl3() { + ETCDCTL_API=3 /usr/bin/etcdctl --cert /etc/etcd/peer.crt --key /etc/etcd/peer.key --cacert /etc/etcd/ca.crt --endpoints https://`hostname`:2379 ${@} +} diff --git a/roles/etcd/tasks/etcdctl.yml b/roles/etcd/tasks/etcdctl.yml new file mode 100644 index 000000000..32c176449 --- /dev/null +++ b/roles/etcd/tasks/etcdctl.yml @@ -0,0 +1,11 @@ +- name: Install etcd for etcdctl +  action: "{{ ansible_pkg_mgr }} name=etcd state=present" +  when: not openshift.common.is_atomic | bool + +- name: Configure etcd profile.d alises +  copy: +    src: etcdctl.sh +    dest: /etc/profile.d/etcdctl.sh +    mode: 0755 +    owner: root +    group: root diff --git a/roles/etcd/tasks/main.yml b/roles/etcd/tasks/main.yml index 2bc6a8678..790eb3c5a 100644 --- a/roles/etcd/tasks/main.yml +++ b/roles/etcd/tasks/main.yml @@ -74,5 +74,8 @@      enabled: yes    register: start_result +- include: etcdctl.yml +  when: openshift_etcd_etcdctl_profile | default(true) | bool +  - set_fact:      etcd_service_status_changed: "{{ start_result | changed }}" diff --git a/roles/openshift_examples/files/examples/v1.4/image-streams/dotnet_imagestreams.json b/roles/openshift_examples/files/examples/v1.4/image-streams/dotnet_imagestreams.json index 00b363c42..a65d35c2e 100644 --- a/roles/openshift_examples/files/examples/v1.4/image-streams/dotnet_imagestreams.json +++ b/roles/openshift_examples/files/examples/v1.4/image-streams/dotnet_imagestreams.json @@ -12,14 +12,18 @@              "kind": "ImageStream",              "apiVersion": "v1",              "metadata": { -                "name": "dotnet" +                "name": "dotnet", +                "annotations": { +                    "openshift.io/display-name": ".NET Core" +                }              },              "spec": {                  "tags": [                      {                          "name": "latest",                          "annotations": { -                          "description": "Build and run .NET Core 1.0 applications", +                          "openshift.io/display-name": ".NET Core (Latest)", +                          "description": "Build and run .NET Core applications on RHEL 7. For more information about using this builder image, including OpenShift considerations, see https://github.com/redhat-developer/s2i-dotnetcore/tree/master/1.0/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version of .NET Core available on OpenShift, including major versions updates.",                            "iconClass": "icon-dotnet",                            "tags": "builder,.net,dotnet,dotnetcore",                            "supports":"dotnet", @@ -34,7 +38,8 @@                      {                          "name": "1.0",                          "annotations": { -                            "description": "Build and run .NET Core 1.0 applications", +                            "openshift.io/display-name": ".NET Core 1.0", +                            "description": "Build and run .NET Core 1.0 applications on RHEL 7. For more information about using this builder image, including OpenShift considerations, see https://github.com/redhat-developer/s2i-dotnetcore/tree/master/1.0/README.md.",                              "iconClass": "icon-dotnet",                              "tags": "builder,.net,dotnet,dotnetcore,rh-dotnetcore10",                              "supports":"dotnet:1.0,dotnet", diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py index a28b58e85..d797eb4d3 100755 --- a/roles/openshift_facts/library/openshift_facts.py +++ b/roles/openshift_facts/library/openshift_facts.py @@ -1595,7 +1595,7 @@ def set_container_facts_if_unset(facts):          cli_image = master_image          node_image = 'openshift3/node'          ovs_image = 'openshift3/openvswitch' -        etcd_image = 'registry.access.redhat.com/rhel7/etcd' +        etcd_image = 'registry.access.redhat.com/rhel7/etcd3'          pod_image = 'openshift3/ose-pod'          router_image = 'openshift3/ose-haproxy-router'          registry_image = 'openshift3/ose-docker-registry' @@ -1605,7 +1605,7 @@ def set_container_facts_if_unset(facts):          cli_image = master_image          node_image = 'aep3_beta/node'          ovs_image = 'aep3_beta/openvswitch' -        etcd_image = 'registry.access.redhat.com/rhel7/etcd' +        etcd_image = 'registry.access.redhat.com/rhel7/etcd3'          pod_image = 'aep3_beta/aep-pod'          router_image = 'aep3_beta/aep-haproxy-router'          registry_image = 'aep3_beta/aep-docker-registry' @@ -1615,7 +1615,7 @@ def set_container_facts_if_unset(facts):          cli_image = master_image          node_image = 'openshift/node'          ovs_image = 'openshift/openvswitch' -        etcd_image = 'registry.access.redhat.com/rhel7/etcd' +        etcd_image = 'registry.access.redhat.com/rhel7/etcd3'          pod_image = 'openshift/origin-pod'          router_image = 'openshift/origin-haproxy-router'          registry_image = 'openshift/origin-docker-registry' diff --git a/roles/openshift_hosted_logging/tasks/deploy_logging.yaml b/roles/openshift_hosted_logging/tasks/deploy_logging.yaml index 0162d1fb0..625af9acd 100644 --- a/roles/openshift_hosted_logging/tasks/deploy_logging.yaml +++ b/roles/openshift_hosted_logging/tasks/deploy_logging.yaml @@ -40,7 +40,7 @@    - name: "Create templates for logging accounts and the deployer"      command: > -      {{ openshift.common.client_binary }} create +      {{ openshift.common.client_binary }} create --config={{ mktemp.stdout }}/admin.kubeconfig        -f {{ hosted_base }}/logging-deployer.yaml        --config={{ mktemp.stdout }}/admin.kubeconfig        -n logging @@ -49,28 +49,41 @@      changed_when: "'created' in logging_import_template.stdout"    - name: "Process the logging accounts template" -    shell:  "{{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig process logging-deployer-account-template |  {{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig create -f -" +    shell: > +      {{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig +      process logging-deployer-account-template |  {{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig create -f -      register: process_deployer_accounts      failed_when: process_deployer_accounts.rc == 1 and 'already exists' not in process_deployer_accounts.stderr    - name: "Set permissions for logging-deployer service account"      command: > -      {{ openshift.common.client_binary }} adm --config={{ mktemp.stdout }}/admin.kubeconfig policy add-cluster-role-to-user oauth-editor system:serviceaccount:logging:logging-deployer +      {{ openshift.common.client_binary }} adm --config={{ mktemp.stdout }}/admin.kubeconfig +      policy add-cluster-role-to-user oauth-editor system:serviceaccount:logging:logging-deployer      register: permiss_output      failed_when: "permiss_output.rc == 1 and 'exists' not in permiss_output.stderr"    - name: "Set permissions for fluentd"      command: > -      {{ openshift.common.client_binary }} adm policy add-scc-to-user privileged system:serviceaccount:logging:aggregated-logging-fluentd +      {{ openshift.common.client_binary }} adm --config={{ mktemp.stdout }}/admin.kubeconfig +      policy add-scc-to-user privileged system:serviceaccount:logging:aggregated-logging-fluentd      register: fluentd_output      failed_when: "fluentd_output.rc == 1 and 'exists' not in fluentd_output.stderr"    - name: "Set additional permissions for fluentd"      command: > -      {{ openshift.common.client_binary }} adm policy add-cluster-role-to-user cluster-reader system:serviceaccount:logging:aggregated-logging-fluentd +      {{ openshift.common.client_binary }} adm policy --config={{ mktemp.stdout }}/admin.kubeconfig +      add-cluster-role-to-user cluster-reader system:serviceaccount:logging:aggregated-logging-fluentd      register: fluentd2_output      failed_when: "fluentd2_output.rc == 1 and 'exists' not in fluentd2_output.stderr" +  - name: "Add rolebinding-reader to aggregated-logging-elasticsearch" +    command: > +      {{ openshift.common.client_binary }} adm --config={{ mktemp.stdout }}/admin.kubeconfig +      policy add-cluster-role-to-user rolebinding-reader \ +      system:serviceaccount:logging:aggregated-logging-elasticsearch +    register: rolebinding_reader_output +    failed_when: "rolebinding_reader_output == 1 and 'exists' not in rolebinding_reader_output.stderr" +    - name: "Create ConfigMap for deployer parameters"      command: >        {{ openshift.common.client_binary}} --config={{ mktemp.stdout }}/admin.kubeconfig create configmap logging-deployer {{ deployer_cmap_params }} diff --git a/roles/openshift_hosted_templates/files/v1.4/enterprise/logging-deployer.yaml b/roles/openshift_hosted_templates/files/v1.4/enterprise/logging-deployer.yaml index 9cff9daca..ddfda1272 100644 --- a/roles/openshift_hosted_templates/files/v1.4/enterprise/logging-deployer.yaml +++ b/roles/openshift_hosted_templates/files/v1.4/enterprise/logging-deployer.yaml @@ -66,6 +66,15 @@ items:        - watch        - delete        - update +  - apiVersion: v1 +    kind: ClusterRole +    metadata: +      name: rolebinding-reader +    rules: +    - resources: +      - clusterrolebindings +      verbs: +      - get    -      apiVersion: v1      kind: RoleBinding @@ -88,6 +97,17 @@ items:      subjects:      - kind: ServiceAccount        name: logging-deployer +  - +    apiVersion: v1 +    kind: RoleBinding +    metadata: +      name: logging-elasticsearch-view-role +    roleRef: +      kind: ClusterRole +      name: view +    subjects: +    - kind: ServiceAccount +      name: aggregated-logging-elasticsearch  -    apiVersion: "v1"    kind: "Template" diff --git a/roles/openshift_hosted_templates/files/v1.4/enterprise/metrics-deployer.yaml b/roles/openshift_hosted_templates/files/v1.4/enterprise/metrics-deployer.yaml index 97a86c11d..66051755c 100644 --- a/roles/openshift_hosted_templates/files/v1.4/enterprise/metrics-deployer.yaml +++ b/roles/openshift_hosted_templates/files/v1.4/enterprise/metrics-deployer.yaml @@ -86,6 +86,8 @@ objects:            value: ${HEAPSTER_NODE_ID}          - name: METRIC_RESOLUTION            value: ${METRIC_RESOLUTION} +        - name: STARTUP_TIMEOUT +          value: ${STARTUP_TIMEOUT}      dnsPolicy: ClusterFirst      restartPolicy: Never      serviceAccount: metrics-deployer @@ -160,3 +162,7 @@ parameters:    description: "How often metrics should be gathered. Defaults value of '15s' for 15 seconds"    name: METRIC_RESOLUTION    value: "15s" +- +  description: "How long in seconds we should wait until Hawkular Metrics and Heapster starts up before attempting a restart" +  name: STARTUP_TIMEOUT +  value: "500" diff --git a/roles/openshift_hosted_templates/files/v1.4/origin/metrics-deployer.yaml b/roles/openshift_hosted_templates/files/v1.4/origin/metrics-deployer.yaml index 5f2290419..54691572a 100644 --- a/roles/openshift_hosted_templates/files/v1.4/origin/metrics-deployer.yaml +++ b/roles/openshift_hosted_templates/files/v1.4/origin/metrics-deployer.yaml @@ -86,6 +86,8 @@ objects:            value: ${HEAPSTER_NODE_ID}          - name: METRIC_RESOLUTION            value: ${METRIC_RESOLUTION} +        - name: STARTUP_TIMEOUT +          value: ${STARTUP_TIMEOUT}      dnsPolicy: ClusterFirst      restartPolicy: Never      serviceAccount: metrics-deployer @@ -160,3 +162,7 @@ parameters:    description: "How often metrics should be gathered. Defaults value of '15s' for 15 seconds"    name: METRIC_RESOLUTION    value: "15s" +- +  description: "How long in seconds we should wait until Hawkular Metrics and Heapster starts up before attempting a restart" +  name: STARTUP_TIMEOUT +  value: "500" diff --git a/roles/openshift_version/tasks/set_version_containerized.yml b/roles/openshift_version/tasks/set_version_containerized.yml index 8e2702391..718537287 100644 --- a/roles/openshift_version/tasks/set_version_containerized.yml +++ b/roles/openshift_version/tasks/set_version_containerized.yml @@ -37,3 +37,8 @@      openshift_version: "{{ cli_image_version.stdout_lines[0].split(' ')[1].split('-')[0:2][1:] | join('-') if openshift.common.deployment_type == 'origin' else cli_image_version.stdout_lines[0].split(' ')[1].split('-')[0][1:] }}"    when: openshift_version is defined and openshift_version.split('.') | length == 2 +# We finally have the specific version. Now we clean up any strange +# dangly +c0mm1t-offset tags in the version. See also, +# openshift_facts.py +- set_fact: +    openshift_version: "{{ openshift_version | oo_chomp_commit_offset }}" diff --git a/roles/os_firewall/README.md b/roles/os_firewall/README.md index 187d74b06..c6c70b81d 100644 --- a/roles/os_firewall/README.md +++ b/roles/os_firewall/README.md @@ -14,7 +14,7 @@ Role Variables  | Name                      | Default |                                        |  |---------------------------|---------|----------------------------------------| -| os_firewall_use_firewalld | True    | If false, use iptables                 | +| os_firewall_use_firewalld | False   | If false, use iptables                 |  | os_firewall_allow         | []      | List of service,port mappings to allow |  | os_firewall_deny          | []      | List of service, port mappings to deny | diff --git a/roles/os_firewall/meta/main.yml b/roles/os_firewall/meta/main.yml index c93335b7b..6df7c9f2b 100644 --- a/roles/os_firewall/meta/main.yml +++ b/roles/os_firewall/meta/main.yml @@ -11,5 +11,6 @@ galaxy_info:      - 7    categories:    - system +allow_duplicates: yes  dependencies:  - { role: openshift_facts }  | 
