kolla-ansible/ansible/roles/baremetal/tasks/install.yml
Pierre Riteau 14bf98ddd5 Make "Check if firewalld is installed" task quieter
Stop showing the task has having made changes and silence warning about
not using the yum module (which we could use for the check, but not as
easily).

Change-Id: I9e3608b5db521930409a29981767f468ea234679
2019-05-22 16:38:54 +01:00

142 lines
3.6 KiB
YAML

---
- name: Update apt cache
apt:
update_cache: yes
become: True
when: ansible_os_family == 'Debian'
# TODO(inc0): Gates don't seem to have ufw executable, check for it instead of ignore errors
- name: Set firewall default policy
become: True
ufw:
state: disabled
policy: allow
when: ansible_os_family == 'Debian'
ignore_errors: yes
- name: Check if firewalld is installed
command: rpm -q firewalld
register: firewalld_check
changed_when: false
failed_when: firewalld_check.rc > 1
args:
warn: false
when: ansible_os_family == 'RedHat'
- name: Disable firewalld
become: True
service:
name: "{{ item }}"
enabled: false
state: stopped
with_items:
- firewalld
when:
- ansible_os_family == 'RedHat'
- firewalld_check.rc == 0
# 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
- name: Install apt packages
package:
name: "{{ (debian_pkg_install | join(' ')).split() }}"
state: present
become: True
when: ansible_os_family == 'Debian'
register: apt_install_result
- name: Install deltarpm packages
package:
name: deltarpm
state: present
update_cache: yes
become: True
when: ansible_os_family == 'RedHat'
- name: Install yum packages
package:
name: "{{ (redhat_pkg_install | join(' ')).split() }}"
state: present
update_cache: yes
become: True
when: ansible_os_family == 'RedHat'
register: yum_install_result
# If any packages were updated, and any containers were running, wait for the
# daemon to come up and start all previously running containers.
- block:
- 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:
install_result: "{{ yum_install_result if ansible_os_family == 'RedHat' else apt_install_result }}"
- name: Install virtualenv packages
package:
name: python-virtualenv
state: present
become: True
when: virtualenv is not none
- name: Install pip
easy_install:
name: pip
virtualenv: "{{ virtualenv is none | ternary(omit, virtualenv) }}"
virtualenv_site_packages: "{{ virtualenv is none | ternary(omit, virtualenv_site_packages) }}"
become: True
when: easy_install_available
- name: Install latest pip in the virtualenv
pip:
name: pip
state: latest
virtualenv: "{{ virtualenv }}"
virtualenv_site_packages: "{{ virtualenv_site_packages }}"
become: True
when: virtualenv is not none
- name: Install docker SDK for python
pip:
name: docker
state: latest
virtualenv: "{{ virtualenv is none | ternary(omit, virtualenv) }}"
virtualenv_site_packages: "{{ virtualenv is none | ternary(omit, virtualenv_site_packages) }}"
become: True
- name: Remove packages
package:
name: "{{ (ubuntu_pkg_removals | join(' ')).split() }}"
state: absent
become: True
when: ansible_distribution|lower == "ubuntu"
- name: Remove packages
package:
name: "{{ (redhat_pkg_removals | join(' ')).split() }}"
state: absent
become: True
when: ansible_os_family == 'RedHat'