Files
tripleo-common/playbooks/roles/octavia-undercloud/tasks/main.yml
Emilien Macchi da97fab4cb ansible: replace yum module by package module when possible
Problem: RHEL and CentOS8 will deprecate the usage of Yum.

From DNF release note:
DNF is the next upcoming major version of yum, a package
manager for RPM-based Linux distributions.
It roughly maintains CLI compatibility with YUM and defines a strict API for
extensions.

Solution: Use "package" Ansible module instead of "yum".

"package" module is smarter when it comes to detect with package manager
runs on the system. The goal of this patch is to support both yum/dnf
(dnf will be the default in rhel/centos 8) from a single ansible module.

Change-Id: Idfc54d80e5186e9ac5ae02f390328d99c2390491
2018-08-06 12:10:41 +00:00

69 lines
2.5 KiB
YAML

---
- name: set file if already set by heat variable (backwards-compatibility)
set_fact:
image_filename: "{{ amp_image_filename }}"
when: amp_image_filename is defined and not amp_image_filename == ''
- name: set location if CentOS
set_fact:
image_filename: "/usr/share/openstack-octavia-amphora-images/amphora-x64-haproxy.qcow2"
when: ansible_distribution == 'CentOS' and not image_filename is defined
- block:
- name: install Octavia amphora image if Red Hat
package:
name: octavia-amphora-image
state: present
become: true
- name: set location if Red Hat
set_fact:
image_filename: "/usr/share/rhosp-director-images/octavia-amphora.qcow2"
when: ansible_distribution == 'RedHat' and not image_filename is defined
- name: check if amphora image file exists
stat:
path: "{{ image_filename }}"
follow: true
get_md5: true
register: image_file_result
- include_tasks: image_mgmt.yml
when: image_file_result.stat.exists
- name: use ssh pub key file if provided and is readable
block:
- name: check if pub key file exists
stat: path="{{ amp_ssh_key_path }}"
register: key_file_result
ignore_errors: true
- name: fail if ssh pub key file does not exist or is not readable
fail: msg="{{ amp_ssh_key_path }} does not exist or is not readable by user {{ ansible_user }}"
when: key_file_result|failed or key_file_result.stat.exists == False or key_file_result.stat.readable == False
- set_fact:
amp_ssh_key_path_final: "{{ amp_ssh_key_path }}"
when: amp_ssh_key_path is defined and amp_ssh_key_path != ""
- name: defaulting to public key from undercloud default keypair
block:
- name: create temp pub key file
tempfile: state=file
register: ssh_key_tmp_file
- name: copy ssh public key content to temp file
copy: content="{{ amp_ssh_key_data }}" dest="{{ ssh_key_tmp_file.path }}"
- set_fact:
amp_ssh_key_path_final: "{{ ssh_key_tmp_file.path }}"
when: amp_ssh_key_path is not defined or amp_ssh_key_path == ""
- name: upload pub key to overcloud
shell: |
openstack keypair show {{ amp_ssh_key_name }} || \
openstack keypair create --public-key {{ amp_ssh_key_path_final }} {{ amp_ssh_key_name }}
environment:
OS_USERNAME: "{{ auth_username }}"
OS_PASSWORD: "{{ auth_password }}"
OS_PROJECT_NAME: "{{ auth_project_name }}"