2020-04-01 10:10:25 +11:00
|
|
|
# If install_ansible_version is not defined (note; not *empty*) it
|
|
|
|
# should be "latest"
|
2018-11-07 07:50:17 +11:00
|
|
|
- name: Set ansible default version to latest
|
|
|
|
set_fact:
|
|
|
|
install_ansible_version: latest
|
|
|
|
when: install_ansible_version is not defined
|
|
|
|
|
|
|
|
# If a version is not explicitly set we want to make sure to
|
2020-04-01 10:10:25 +11:00
|
|
|
# completely omit the version argument to pip:, as it will be coming
|
2018-11-07 07:50:17 +11:00
|
|
|
# from the long-form install_ansible_name variable. Additionally, if
|
|
|
|
# the version is the special value "latest", then we also want to omit
|
|
|
|
# any version number, but also set the package state to "latest".
|
|
|
|
- name: Set ansible version for installation
|
|
|
|
set_fact:
|
|
|
|
_install_ansible_version: '{{ install_ansible_version }}'
|
|
|
|
when: install_ansible_version not in ('', 'latest')
|
|
|
|
|
|
|
|
- name: Set ansible package state for installation
|
|
|
|
set_fact:
|
|
|
|
_install_ansible_state: latest
|
|
|
|
when: install_ansible_version == 'latest'
|
|
|
|
|
2020-04-01 10:10:25 +11:00
|
|
|
# Since Ansible 2.10 (~2020-08) the devel core package is split into
|
|
|
|
# "ansible-base". The PyPi the package "ansible" has everything in it
|
|
|
|
# (the so called Ansible Community Distribution) but we specifically
|
|
|
|
# want to test against devel. However, ARA still depends on the
|
|
|
|
# "ansible" package -- but we like ARA, because we can see the nested
|
|
|
|
# runs with it. To to keep ARA but avoid it bringing in either an old
|
|
|
|
# version of Ansible, or the ACD, install a dummy package.
|
|
|
|
- name: Check if running devel branch
|
|
|
|
set_fact:
|
|
|
|
_install_ansible_from_devel: true
|
|
|
|
when: '"github.com/ansible/ansible" in install_ansible_name'
|
|
|
|
|
2020-11-18 10:02:56 +11:00
|
|
|
# Since ~2020-11 ansible renamed "ansible-base" to "ansible-core".
|
|
|
|
# Unfortunately, ansible-base and ansible-core can not live happily
|
|
|
|
# together. For testinfra, our tox role pre-installs the requirements
|
|
|
|
# from tox.ini (ansible-base) but then tries to install siblings (the
|
|
|
|
# checked out ansible tree, now trying to install the "ansible-core"
|
|
|
|
# package). There is no working "ansible-core" package on PyPi, so
|
|
|
|
# for now we have to switch this out in the tox.ini for the -devel job
|
|
|
|
# to work. We can remove this when "ansible-core" is published at an
|
|
|
|
# appropriate version on PyPi; at that point the checked-out tree can
|
|
|
|
# override the package in the testing tox venv.
|
|
|
|
- name: Override ansible-base tox install
|
|
|
|
when: '"github.com/ansible/ansible" in install_ansible_name'
|
|
|
|
lineinfile:
|
|
|
|
path: /home/zuul/src/opendev.org/opendev/system-config/tox.ini
|
|
|
|
regexp: '^ ansible-base # see install-ansible/tasks/main\.yaml$'
|
|
|
|
line: ' ansible-core'
|
|
|
|
|
2020-04-01 10:10:25 +11:00
|
|
|
- name: Setup Ansible stub for post 2.10 compat
|
|
|
|
include_tasks: install_ansible_stub.yaml
|
|
|
|
when: _install_ansible_from_devel is defined
|
|
|
|
|
|
|
|
# From Ansible 2.10 >= most of the fun stuff is in collections. Clone
|
|
|
|
# our required collections here. Note, in production, we use ACD
|
|
|
|
# which bundles most of this.
|
|
|
|
#
|
|
|
|
# TODO(ianw): we should add these to zuul and link the speculative
|
|
|
|
# copies into ansible, then we could test changes in the collections!
|
|
|
|
- name: Install Ansible collections
|
|
|
|
include_tasks: install_ansible_collection.yaml
|
|
|
|
when: _install_ansible_from_devel is defined
|
|
|
|
loop:
|
2020-08-24 09:56:38 +10:00
|
|
|
- namespace: ansible
|
|
|
|
name: netcommon
|
|
|
|
repo: ansible-collections/ansible.netcommon
|
2020-04-01 10:10:25 +11:00
|
|
|
- namespace: ansible
|
|
|
|
name: posix
|
2020-08-24 09:56:38 +10:00
|
|
|
repo: ansible-collections/ansible.posix
|
2020-04-01 10:10:25 +11:00
|
|
|
- namespace: community
|
|
|
|
name: general
|
2020-08-24 09:56:38 +10:00
|
|
|
repo: ansible-collections/community.general
|
2020-04-01 10:10:25 +11:00
|
|
|
- namespace: community
|
|
|
|
name: crypto
|
2020-08-24 09:56:38 +10:00
|
|
|
repo: ansible-collections/community.crypto
|
2020-04-01 10:10:25 +11:00
|
|
|
|
|
|
|
- name: Ensure required Ansible build packages for non-wheel architectures
|
2019-10-25 16:27:53 +11:00
|
|
|
apt:
|
|
|
|
update_cache: yes
|
|
|
|
name:
|
|
|
|
- libffi-dev
|
|
|
|
- libssl-dev
|
|
|
|
- build-essential
|
|
|
|
when: ansible_architecture == 'aarch64'
|
|
|
|
|
2018-08-01 14:13:25 -05:00
|
|
|
- name: Install ansible
|
|
|
|
pip:
|
2018-11-07 07:50:17 +11:00
|
|
|
name: '{{ install_ansible_name | default("ansible") }}'
|
|
|
|
version: '{{ _install_ansible_version | default(omit) }}'
|
|
|
|
state: '{{ _install_ansible_state | default(omit) }}'
|
2018-08-01 14:13:25 -05:00
|
|
|
|
2020-04-01 10:10:25 +11:00
|
|
|
- name: Ansible version check
|
|
|
|
command: 'ansible-playbook --version'
|
|
|
|
register: _ansible_version_check
|
|
|
|
|
|
|
|
- name: Sanity check Ansible version
|
|
|
|
debug:
|
|
|
|
msg: '{{ _ansible_version_check.stdout }}'
|
|
|
|
|
|
|
|
- name: Ansible cmd version check
|
|
|
|
command: 'ansible --version'
|
|
|
|
register: _ansible_version_check
|
|
|
|
|
|
|
|
- name: Sanity check Ansible version
|
|
|
|
debug:
|
|
|
|
msg: '{{ _ansible_version_check.stdout }}'
|
|
|
|
|
|
|
|
- name: Set up the ARA callback
|
|
|
|
include_tasks: install_ara.yaml
|
|
|
|
when: install_ansible_ara_enable
|
|
|
|
|
2018-12-20 13:02:10 -08:00
|
|
|
# For use by k8s_raw ansible module
|
2019-02-14 10:19:59 -08:00
|
|
|
# - name: Install openshift client
|
|
|
|
# pip:
|
|
|
|
# name: 'openshift'
|
|
|
|
# TODO(corvus): re-add this once kubernetes 9.0.0 is released
|
2018-12-20 13:02:10 -08:00
|
|
|
|
2018-11-07 08:12:20 +11:00
|
|
|
# Same version/state default swizzling as described above for
|
|
|
|
# openstacksdk
|
|
|
|
- name: Set openstacksdk default version to latest
|
|
|
|
set_fact:
|
2018-12-04 17:42:06 -05:00
|
|
|
install_ansible_openstacksdk_version: latest
|
|
|
|
when: install_ansible_openstacksdk_version is not defined
|
2018-11-07 08:12:20 +11:00
|
|
|
|
|
|
|
- name: Set openstacksdk version for installation
|
|
|
|
set_fact:
|
2018-12-04 17:42:06 -05:00
|
|
|
_install_ansible_openstacksdk_version: '{{ install_ansible_openstacksdk_version }}'
|
|
|
|
when: install_ansible_openstacksdk_version not in ('', 'latest')
|
2018-11-07 08:12:20 +11:00
|
|
|
|
|
|
|
- name: Set openstacksdk package state for installation
|
|
|
|
set_fact:
|
|
|
|
_install_openstacksdk_state: latest
|
2018-12-04 17:42:06 -05:00
|
|
|
when: install_ansible_openstacksdk_version == 'latest'
|
2018-11-07 08:12:20 +11:00
|
|
|
|
2018-08-01 14:13:25 -05:00
|
|
|
- name: Install openstacksdk
|
|
|
|
pip:
|
2018-12-04 17:42:06 -05:00
|
|
|
name: '{{ install_ansible_openstacksdk_name | default("openstacksdk") }}'
|
|
|
|
version: '{{ _install_ansible_openstacksdk_version | default(omit) }}'
|
2018-11-07 08:12:20 +11:00
|
|
|
state: '{{ _install_openstacksdk_state | default(omit) }}'
|
2018-08-01 14:13:25 -05:00
|
|
|
|
2021-03-03 14:06:14 +11:00
|
|
|
# NOTE(ianw) 2021-03-03 stevedore < 3.3.0 has a bug where it creates a
|
|
|
|
# constantly expanding set of cache files in
|
|
|
|
# /root/.cache/python-endpoints when run under ansible in a /tmp
|
|
|
|
# directory (this happens via cloud-launcher and openstacksdk).
|
|
|
|
# Ensure the production host is updated, and drop a .disable file
|
|
|
|
# for good measure
|
|
|
|
- name: Ensure stevedore >= 3.3.0
|
|
|
|
pip:
|
|
|
|
name: 'stevedore>=3.3.0'
|
|
|
|
- name: Add stevedore cache dir
|
|
|
|
file:
|
|
|
|
path: /root/.cache/python-entrypoints/
|
|
|
|
state: directory
|
|
|
|
mode: 0700
|
|
|
|
- name: Add stevedore cache disable file
|
|
|
|
file:
|
|
|
|
path: /root/.cache/python-entrypoints/.disable
|
|
|
|
state: touch
|
|
|
|
mode: 0600
|
|
|
|
|
2018-08-01 14:13:25 -05:00
|
|
|
- name: Ensure /etc/ansible and /etc/ansible/hosts
|
|
|
|
file:
|
|
|
|
state: directory
|
|
|
|
path: /etc/ansible/hosts
|
|
|
|
|
|
|
|
- name: Ensure /etc/ansible/inventory_plugins
|
|
|
|
file:
|
|
|
|
state: directory
|
|
|
|
path: /etc/ansible/inventory_plugins
|
|
|
|
|
|
|
|
- name: Ensure /var/cache/ansible
|
|
|
|
file:
|
|
|
|
state: directory
|
|
|
|
path: /var/cache/ansible
|
|
|
|
owner: root
|
2018-08-23 14:27:50 +10:00
|
|
|
group: root
|
2018-08-01 14:13:25 -05:00
|
|
|
mode: 0770
|
|
|
|
|
2018-08-17 12:56:27 -05:00
|
|
|
- name: Ensure ansible log dir is writable
|
2018-08-01 14:13:25 -05:00
|
|
|
file:
|
2018-08-17 12:56:27 -05:00
|
|
|
path: /var/log/ansible
|
|
|
|
state: directory
|
2018-08-01 14:13:25 -05:00
|
|
|
owner: root
|
2018-08-23 14:27:50 +10:00
|
|
|
group: root
|
2018-08-17 12:56:27 -05:00
|
|
|
mode: 0775
|
2018-08-01 14:13:25 -05:00
|
|
|
|
|
|
|
- name: Copy ansible.cfg in to place
|
2018-10-16 23:46:29 -04:00
|
|
|
template:
|
|
|
|
src: ansible.cfg.j2
|
2018-08-01 14:13:25 -05:00
|
|
|
dest: /etc/ansible/ansible.cfg
|
|
|
|
|
2020-05-26 15:46:41 -05:00
|
|
|
- name: Remove old inventory files
|
|
|
|
file:
|
|
|
|
path: '/etc/ansible/hosts/{{ item }}'
|
|
|
|
state: absent
|
2020-04-11 09:26:02 -05:00
|
|
|
loop:
|
|
|
|
- openstack.yaml
|
|
|
|
- groups.yaml
|
|
|
|
|
|
|
|
- name: Copy system-config roles into place
|
|
|
|
copy:
|
|
|
|
src: roles/
|
|
|
|
dest: /etc/ansible/roles
|
|
|
|
|
2020-06-12 17:20:08 -05:00
|
|
|
- name: Copy disable-ansible utility script in place
|
|
|
|
copy:
|
|
|
|
src: disable-ansible
|
|
|
|
dest: /usr/local/bin/disable-ansible
|
|
|
|
mode: 0755
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
|
2018-09-12 11:32:42 -06:00
|
|
|
- name: Copy yamlgroup inventory in place
|
|
|
|
copy:
|
|
|
|
src: inventory_plugins/yamlgroup.py
|
|
|
|
dest: /etc/ansible/inventory_plugins/yamlgroup.py
|
2018-08-29 10:49:32 +10:00
|
|
|
|
|
|
|
- name: Setup log rotation
|
|
|
|
include_role:
|
|
|
|
name: logrotate
|
|
|
|
vars:
|
2018-09-12 11:32:42 -06:00
|
|
|
logrotate_file_name: /var/log/ansible/ansible.log
|
2018-11-07 07:50:17 +11:00
|
|
|
|
|
|
|
- name: Verify ansible install
|
|
|
|
command: ansible --version
|