2016-08-04 02:50:31 +00:00
|
|
|
---
|
2016-10-26 22:17:34 +08:00
|
|
|
- name: Update apt cache
|
2018-02-05 15:38:17 +01:00
|
|
|
apt:
|
|
|
|
update_cache: yes
|
2016-09-20 10:31:40 +08:00
|
|
|
become: True
|
2021-05-13 12:21:11 +01:00
|
|
|
when: ansible_facts.os_family == 'Debian'
|
2016-09-20 10:31:40 +08:00
|
|
|
|
2017-05-18 08:20:14 -07:00
|
|
|
# TODO(inc0): Gates don't seem to have ufw executable, check for it instead of ignore errors
|
2016-11-03 11:47:44 +05:30
|
|
|
- name: Set firewall default policy
|
2016-12-08 17:31:15 +08:00
|
|
|
become: True
|
2017-09-19 11:23:20 +02:00
|
|
|
ufw:
|
|
|
|
state: disabled
|
|
|
|
policy: allow
|
2021-05-13 12:21:11 +01:00
|
|
|
when: ansible_facts.os_family == 'Debian'
|
2017-05-18 08:20:14 -07:00
|
|
|
ignore_errors: yes
|
2016-11-03 11:47:44 +05:30
|
|
|
|
|
|
|
- name: Check if firewalld is installed
|
|
|
|
command: rpm -q firewalld
|
|
|
|
register: firewalld_check
|
2019-05-22 16:38:54 +01:00
|
|
|
changed_when: false
|
2016-11-03 11:47:44 +05:30
|
|
|
failed_when: firewalld_check.rc > 1
|
2019-05-22 16:38:54 +01:00
|
|
|
args:
|
|
|
|
warn: false
|
2021-05-13 12:21:11 +01:00
|
|
|
when: ansible_facts.os_family == 'RedHat'
|
2016-11-03 11:47:44 +05:30
|
|
|
|
|
|
|
- name: Disable firewalld
|
|
|
|
become: True
|
|
|
|
service:
|
|
|
|
name: "{{ item }}"
|
|
|
|
enabled: false
|
|
|
|
state: stopped
|
|
|
|
with_items:
|
|
|
|
- firewalld
|
|
|
|
when:
|
2021-05-13 12:21:11 +01:00
|
|
|
- ansible_facts.os_family == 'RedHat'
|
2017-02-24 17:45:08 +08:00
|
|
|
- firewalld_check.rc == 0
|
2016-11-03 11:47:44 +05:30
|
|
|
|
Support Docker CE in bootstrap-servers
Kolla Ansible's bootstrap-servers command provides support for
installing the Docker engine. This is currently done using the packages
at https://apt.dockerproject.org and https://yum.dockerproject.org.
These packages are outdated, with the most recent packages from May 2017
- docker-engine-17.05.
The source for up to date docker packages is
https://download.docker.com, which was introduced with the move to
Docker Community Edition (CE) and Docker Enterprise Edition (EE).
This change adds support to bootstrap-servers for Docker CE for CentOS
and Ubuntu.
It also adds a new variable, 'enable_docker_repo', which controls
whether a package repository for Docker will be enabled.
It also adds a new variable, 'docker_legacy_packages', which controls
whether the legacy packages at dockerproject.org will be used or the
newer packages at docker.com. The default value for this variable is
'false', meaning to use Docker CE.
Upgrading from docker-engine to docker-ce has been tested on CentOS 7.5
and Ubuntu 16.04, by running 'kolla-ansible bootstrap-servers' with
'docker_legacy_packages' set to 'false'. The upgrades were successful,
but result in all containers being stopped. For this reason, the
bootstrap-servers command checks running containers prior to upgrading
packages, and ensures they are running after the package upgrade is
complete.
As mentioned in the release note, care should be taken when upgrading
Docker with clustered services, which could lose quorum. To avoid this,
use --serial or --limit to apply the change in batches.
Change-Id: I6dfd375c868870f8646ef1a8f02c70812e8f6271
Implements: blueprint docker-ce
2018-07-13 15:49:30 +01:00
|
|
|
# Upgrading docker engine may cause containers to stop. Take a snapshot of the
|
|
|
|
# running containers prior to a potential upgrade of Docker.
|
|
|
|
|
|
|
|
- name: Check which containers are running
|
|
|
|
command: docker ps -f 'status=running' -q
|
|
|
|
become: true
|
|
|
|
# If Docker is not installed this command may exit non-zero.
|
|
|
|
failed_when: false
|
|
|
|
changed_when: false
|
|
|
|
register: running_containers
|
|
|
|
|
2021-04-23 12:41:43 +02:00
|
|
|
# APT starts Docker engine right after installation, which creates
|
|
|
|
# iptables rules before we disable iptables in Docker config
|
|
|
|
|
|
|
|
- name: Check if docker systemd unit exists
|
|
|
|
stat:
|
|
|
|
path: /etc/systemd/system/docker.service
|
|
|
|
register: docker_unit_file
|
|
|
|
|
|
|
|
- name: Mask the docker systemd unit on Debian/Ubuntu
|
|
|
|
file:
|
|
|
|
src: /dev/null
|
|
|
|
dest: /etc/systemd/system/docker.service
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
state: link
|
|
|
|
become: true
|
|
|
|
when:
|
2021-05-13 12:21:11 +01:00
|
|
|
- ansible_facts.os_family == 'Debian'
|
2021-04-23 12:41:43 +02:00
|
|
|
- not docker_unit_file.stat.exists
|
|
|
|
|
2016-10-26 22:17:34 +08:00
|
|
|
- name: Install apt packages
|
2017-09-19 11:23:20 +02:00
|
|
|
package:
|
2019-05-09 15:08:27 +08:00
|
|
|
name: "{{ (debian_pkg_install | join(' ')).split() }}"
|
2017-09-19 11:23:20 +02:00
|
|
|
state: present
|
2016-09-20 10:31:40 +08:00
|
|
|
become: True
|
2021-05-13 12:21:11 +01:00
|
|
|
when: ansible_facts.os_family == 'Debian'
|
Support Docker CE in bootstrap-servers
Kolla Ansible's bootstrap-servers command provides support for
installing the Docker engine. This is currently done using the packages
at https://apt.dockerproject.org and https://yum.dockerproject.org.
These packages are outdated, with the most recent packages from May 2017
- docker-engine-17.05.
The source for up to date docker packages is
https://download.docker.com, which was introduced with the move to
Docker Community Edition (CE) and Docker Enterprise Edition (EE).
This change adds support to bootstrap-servers for Docker CE for CentOS
and Ubuntu.
It also adds a new variable, 'enable_docker_repo', which controls
whether a package repository for Docker will be enabled.
It also adds a new variable, 'docker_legacy_packages', which controls
whether the legacy packages at dockerproject.org will be used or the
newer packages at docker.com. The default value for this variable is
'false', meaning to use Docker CE.
Upgrading from docker-engine to docker-ce has been tested on CentOS 7.5
and Ubuntu 16.04, by running 'kolla-ansible bootstrap-servers' with
'docker_legacy_packages' set to 'false'. The upgrades were successful,
but result in all containers being stopped. For this reason, the
bootstrap-servers command checks running containers prior to upgrading
packages, and ensures they are running after the package upgrade is
complete.
As mentioned in the release note, care should be taken when upgrading
Docker with clustered services, which could lose quorum. To avoid this,
use --serial or --limit to apply the change in batches.
Change-Id: I6dfd375c868870f8646ef1a8f02c70812e8f6271
Implements: blueprint docker-ce
2018-07-13 15:49:30 +01:00
|
|
|
register: apt_install_result
|
2016-09-20 10:31:40 +08:00
|
|
|
|
2016-10-26 22:17:34 +08:00
|
|
|
- name: Install deltarpm packages
|
2017-09-19 11:23:20 +02:00
|
|
|
package:
|
2020-03-16 15:58:11 +00:00
|
|
|
name: drpm
|
2018-12-06 14:21:55 +00:00
|
|
|
state: present
|
2019-03-08 14:36:08 +00:00
|
|
|
update_cache: yes
|
2016-09-20 10:31:40 +08:00
|
|
|
become: True
|
2021-05-13 12:21:11 +01:00
|
|
|
when: ansible_facts.os_family == 'RedHat'
|
2016-09-20 10:31:40 +08:00
|
|
|
|
2019-12-06 16:27:26 +00:00
|
|
|
- name: Install RPM packages
|
2017-09-19 11:23:20 +02:00
|
|
|
package:
|
2019-05-09 15:08:27 +08:00
|
|
|
name: "{{ (redhat_pkg_install | join(' ')).split() }}"
|
2017-09-19 11:23:20 +02:00
|
|
|
state: present
|
2019-03-08 14:36:08 +00:00
|
|
|
update_cache: yes
|
2016-09-20 10:31:40 +08:00
|
|
|
become: True
|
2021-05-13 12:21:11 +01:00
|
|
|
when: ansible_facts.os_family == 'RedHat'
|
2019-12-06 16:27:26 +00:00
|
|
|
register: rpm_install_result
|
Support Docker CE in bootstrap-servers
Kolla Ansible's bootstrap-servers command provides support for
installing the Docker engine. This is currently done using the packages
at https://apt.dockerproject.org and https://yum.dockerproject.org.
These packages are outdated, with the most recent packages from May 2017
- docker-engine-17.05.
The source for up to date docker packages is
https://download.docker.com, which was introduced with the move to
Docker Community Edition (CE) and Docker Enterprise Edition (EE).
This change adds support to bootstrap-servers for Docker CE for CentOS
and Ubuntu.
It also adds a new variable, 'enable_docker_repo', which controls
whether a package repository for Docker will be enabled.
It also adds a new variable, 'docker_legacy_packages', which controls
whether the legacy packages at dockerproject.org will be used or the
newer packages at docker.com. The default value for this variable is
'false', meaning to use Docker CE.
Upgrading from docker-engine to docker-ce has been tested on CentOS 7.5
and Ubuntu 16.04, by running 'kolla-ansible bootstrap-servers' with
'docker_legacy_packages' set to 'false'. The upgrades were successful,
but result in all containers being stopped. For this reason, the
bootstrap-servers command checks running containers prior to upgrading
packages, and ensures they are running after the package upgrade is
complete.
As mentioned in the release note, care should be taken when upgrading
Docker with clustered services, which could lose quorum. To avoid this,
use --serial or --limit to apply the change in batches.
Change-Id: I6dfd375c868870f8646ef1a8f02c70812e8f6271
Implements: blueprint docker-ce
2018-07-13 15:49:30 +01:00
|
|
|
|
|
|
|
# If any packages were updated, and any containers were running, wait for the
|
|
|
|
# daemon to come up and start all previously running containers.
|
|
|
|
|
|
|
|
- block:
|
2019-11-11 11:13:37 +00:00
|
|
|
# At some point (at least on CentOS 7) Docker CE stopped starting
|
|
|
|
# automatically after an upgrade from legacy docker . Start it manually.
|
|
|
|
- name: Start docker
|
2021-04-23 12:41:43 +02:00
|
|
|
systemd:
|
2019-11-11 11:13:37 +00:00
|
|
|
name: docker
|
|
|
|
state: started
|
|
|
|
enabled: yes
|
2021-04-23 12:41:43 +02:00
|
|
|
masked: no
|
2019-11-11 11:13:37 +00:00
|
|
|
become: True
|
|
|
|
|
Support Docker CE in bootstrap-servers
Kolla Ansible's bootstrap-servers command provides support for
installing the Docker engine. This is currently done using the packages
at https://apt.dockerproject.org and https://yum.dockerproject.org.
These packages are outdated, with the most recent packages from May 2017
- docker-engine-17.05.
The source for up to date docker packages is
https://download.docker.com, which was introduced with the move to
Docker Community Edition (CE) and Docker Enterprise Edition (EE).
This change adds support to bootstrap-servers for Docker CE for CentOS
and Ubuntu.
It also adds a new variable, 'enable_docker_repo', which controls
whether a package repository for Docker will be enabled.
It also adds a new variable, 'docker_legacy_packages', which controls
whether the legacy packages at dockerproject.org will be used or the
newer packages at docker.com. The default value for this variable is
'false', meaning to use Docker CE.
Upgrading from docker-engine to docker-ce has been tested on CentOS 7.5
and Ubuntu 16.04, by running 'kolla-ansible bootstrap-servers' with
'docker_legacy_packages' set to 'false'. The upgrades were successful,
but result in all containers being stopped. For this reason, the
bootstrap-servers command checks running containers prior to upgrading
packages, and ensures they are running after the package upgrade is
complete.
As mentioned in the release note, care should be taken when upgrading
Docker with clustered services, which could lose quorum. To avoid this,
use --serial or --limit to apply the change in batches.
Change-Id: I6dfd375c868870f8646ef1a8f02c70812e8f6271
Implements: blueprint docker-ce
2018-07-13 15:49:30 +01:00
|
|
|
- name: Wait for Docker to start
|
|
|
|
command: docker info
|
|
|
|
become: true
|
|
|
|
changed_when: false
|
|
|
|
register: result
|
|
|
|
until: result is success
|
|
|
|
retries: 6
|
|
|
|
delay: 10
|
|
|
|
|
|
|
|
- name: Ensure containers are running after Docker upgrade
|
|
|
|
command: "docker start {{ running_containers.stdout }}"
|
|
|
|
become: true
|
|
|
|
when:
|
|
|
|
- install_result is changed
|
|
|
|
- running_containers.rc == 0
|
|
|
|
- running_containers.stdout != ''
|
|
|
|
vars:
|
2021-05-13 12:21:11 +01:00
|
|
|
install_result: "{{ rpm_install_result if ansible_facts.os_family == 'RedHat' else apt_install_result }}"
|
2017-12-07 11:44:05 +00:00
|
|
|
|
|
|
|
- name: Install latest pip in the virtualenv
|
|
|
|
pip:
|
2020-01-13 10:41:04 +00:00
|
|
|
# NOTE(hrw) pip 19.3 is first version complaining about being run with Python 2
|
|
|
|
name: pip>19.3
|
2017-12-07 11:44:05 +00:00
|
|
|
virtualenv: "{{ virtualenv }}"
|
|
|
|
virtualenv_site_packages: "{{ virtualenv_site_packages }}"
|
2019-12-06 16:27:26 +00:00
|
|
|
virtualenv_python: "python{{ host_python_version }}"
|
2017-12-07 11:44:05 +00:00
|
|
|
become: True
|
|
|
|
when: virtualenv is not none
|
|
|
|
|
2017-06-20 22:21:21 +00:00
|
|
|
- name: Install docker SDK for python
|
2017-09-19 11:23:20 +02:00
|
|
|
pip:
|
2020-01-13 10:41:04 +00:00
|
|
|
# NOTE(hrw) docker 2.4.2 is in kolla-ansible requirements
|
2021-05-19 08:08:42 +02:00
|
|
|
# NOTE(mnasiadka): docker 5.0.0 lacks six in deps but requires it
|
|
|
|
name: docker>=2.4.2,<5.0.0
|
2020-03-16 16:18:42 +00:00
|
|
|
executable: "{{ virtualenv is none | ternary('pip3', omit) }}"
|
2017-12-07 11:44:05 +00:00
|
|
|
virtualenv: "{{ virtualenv is none | ternary(omit, virtualenv) }}"
|
|
|
|
virtualenv_site_packages: "{{ virtualenv is none | ternary(omit, virtualenv_site_packages) }}"
|
2019-12-06 16:27:26 +00:00
|
|
|
virtualenv_python: "{{ virtualenv is none | ternary(omit, 'python' ~ host_python_version) }}"
|
2017-12-07 11:44:05 +00:00
|
|
|
become: True
|
|
|
|
|
2016-10-26 22:17:34 +08:00
|
|
|
- name: Remove packages
|
2017-09-19 11:23:20 +02:00
|
|
|
package:
|
2019-05-09 15:08:27 +08:00
|
|
|
name: "{{ (ubuntu_pkg_removals | join(' ')).split() }}"
|
2017-09-19 11:23:20 +02:00
|
|
|
state: absent
|
2016-09-20 10:31:40 +08:00
|
|
|
become: True
|
2021-05-13 12:21:11 +01:00
|
|
|
when: ansible_facts.os_family == 'Debian'
|
2016-09-20 10:31:40 +08:00
|
|
|
|
2016-10-26 22:17:34 +08:00
|
|
|
- name: Remove packages
|
2017-09-19 11:23:20 +02:00
|
|
|
package:
|
2019-05-09 15:08:27 +08:00
|
|
|
name: "{{ (redhat_pkg_removals | join(' ')).split() }}"
|
2017-09-19 11:23:20 +02:00
|
|
|
state: absent
|
2016-09-20 10:31:40 +08:00
|
|
|
become: True
|
2021-05-13 12:21:11 +01:00
|
|
|
when: ansible_facts.os_family == 'RedHat'
|