Support Ocata split of kolla-ansible from kolla, allow custom kolla passwords

This commit is contained in:
Mark Goddard 2017-02-17 12:50:13 +00:00
parent d385fe326a
commit aad71bcd25
8 changed files with 185 additions and 33 deletions

View File

@ -12,6 +12,13 @@ kolla_source_url: "https://github.com/stackhpc/kolla"
# 'source'.
kolla_source_version: "stackhpc-{{ kolla_openstack_release }}"
# URL of Kolla Ansible source code repository if type is 'source'.
kolla_ansible_source_url: "https://github.com/stackhpc/kolla-ansible"
# Version (branch, tag, etc.) of Kolla Ansible source code repository if type
# is 'source'.
kolla_ansible_source_version: "stackhpc-{{ kolla_openstack_release }}"
###############################################################################
# Kolla configuration.
@ -45,3 +52,23 @@ kolla_openstack_logging_debug: "False"
kolla_enable_glance: "yes"
kolla_enable_ironic: "yes"
kolla_enable_swift: "yes"
###############################################################################
# Passwords and credentials.
# Dictionary containing default custom passwords to add or override in the
# Kolla passwords file.
kolla_ansible_default_custom_passwords:
# SSH key authorized in hosts deployed by Bifrost.
bifrost_ssh_key:
private_key: "{{ lookup('file', ssh_private_key_path) }}"
public_key: "{{ lookup('file', ssh_public_key_path) }}"
# SSH key authorized by kolla user on Kolla hosts during
# kolla-ansible bootstrap-servers.
kolla_ssh_key:
private_key: "{{ lookup('file', ssh_private_key_path) }}"
public_key: "{{ lookup('file', ssh_public_key_path) }}"
# Dictionary containing custom passwords to add or override in the Kolla
# passwords file.
kolla_ansible_custom_passwords: "{{ kolla_ansible_default_custom_passwords }}"

View File

@ -1,4 +1,17 @@
---
# Path to directory for source code checkouts.
source_checkout_path:
# Type of Kolla control installation. One of 'binary' or 'source'.
kolla_ctl_install_type:
# URL of Kolla Ansible source code repository if type is 'source'.
kolla_ansible_source_url:
# Version (branch, tag, etc.) of Kolla Ansible source code repository if type
# is 'source'.
kolla_ansible_source_version:
# Virtualenv directory where Kolla will be installed.
kolla_venv: "{{ ansible_env['PWD'] }}/kolla-venv"
@ -137,3 +150,7 @@ kolla_openstack_logging_debug:
# Free form extra configuration to append to {{ kolla_config_path }}/globals.yml.
kolla_extra_globals:
# Dictionary containing custom passwords to add or override in the Kolla
# passwords file.
kolla_ansible_custom_passwords: {}

View File

@ -0,0 +1,48 @@
---
- name: Ensure the Kolla Ansible configuration directores exist
file:
path: "{{ item }}"
state: directory
mode: 0755
become: True
with_items:
- "{{ kolla_config_path }}"
- "{{ kolla_config_path }}/inventory"
- "{{ kolla_node_custom_config_path }}"
- name: Ensure the Kolla configuration files exist
template:
src: "{{ item.src }}"
dest: "{{ kolla_config_path }}/{{ item.dest }}"
mode: 0644
become: True
with_items:
- { src: seed.j2, dest: inventory/seed }
- { src: overcloud.j2, dest: inventory/overcloud }
- { src: globals.yml.j2, dest: globals.yml }
- name: Check whether the Kolla passwords file exists
stat:
path: "{{ kolla_config_path }}/passwords.yml"
register: kolla_passwords_stat
- name: Generate Kolla passwords
shell: >
cp {{ kolla_ansible_install_dir }}/etc_examples/kolla/passwords.yml {{ kolla_config_path }}/passwords.yml.generated
&& {{ kolla_venv }}/bin/kolla-genpwd -p {{ kolla_config_path }}/passwords.yml.generated
&& mv {{ kolla_config_path }}/passwords.yml.generated {{ kolla_config_path }}/passwords.yml
become: True
when: not kolla_passwords_stat.stat.exists
- name: Read the Kolla passwords file
slurp:
src: "{{ kolla_config_path }}/passwords.yml"
register: passwords_result
when: "{{ kolla_ansible_custom_passwords }}"
- name: Ensure the Kolla passwords file contains the required custom passwords
copy:
content: "{{ passwords_result.content | b64decode | from_yaml | combine(kolla_ansible_custom_passwords) | to_nice_yaml }}"
dest: "{{ kolla_config_path }}/passwords.yml"
become: True
when: "{{ kolla_ansible_custom_passwords }}"

View File

@ -0,0 +1,48 @@
---
- name: Ensure required packages are installed
yum:
name: "{{ item }}"
state: installed
become: True
with_items:
- gcc
- libffi-devel
- openssl-devel
- patch
- python-devel
- python-pip
- python-virtualenv
- name: Ensure the latest version of pip is installed
pip:
name: "{{ item.name }}"
state: latest
virtualenv: "{{ kolla_venv }}"
with_items:
- { name: pip }
- name: Ensure Kolla Ansible source code checkout exists
git:
repo: "{{ kolla_ansible_source_url }}"
dest: "{{ source_checkout_path }}/kolla-ansible"
version: "{{ kolla_ansible_source_version }}"
when: "{{ kolla_ctl_install_type == 'source' }}"
- name: Ensure required Python packages are installed
pip:
name: "{{ item.name }}"
version: "{{ item.version | default(omit) }}"
state: present
virtualenv: "{{ kolla_venv }}"
with_items:
# Intall Kolla Ansible from source.
- name: "{{ source_checkout_path }}/kolla-ansible"
install: "{{ kolla_ctl_install_type == 'source' }}"
# Intall Kolla Ansible from PyPI.
- name: "kolla-ansible"
version: "{{ kolla_openstack_release }}"
install: "{{ kolla_ctl_install_type == 'binary' }}"
# Required for kolla-genpwd.
- name: PyYAML
version: "3.12"
when: "{{ item.install | default(True) | bool }}"

View File

@ -1,34 +1,5 @@
---
- name: Ensure the Kolla configuration directores exist
file:
path: "{{ item }}"
state: directory
mode: 0755
become: True
with_items:
- "{{ kolla_config_path }}/inventory"
- "{{ kolla_node_custom_config_path }}"
- include: install.yml
when: "{{ kolla_ansible_is_standalone | bool }}"
- name: Ensure the Kolla configuration files exist
template:
src: "{{ item.src }}"
dest: "{{ kolla_config_path }}/{{ item.dest }}"
mode: 0644
become: True
with_items:
- { src: seed.j2, dest: inventory/seed }
- { src: overcloud.j2, dest: inventory/overcloud }
- { src: globals.yml.j2, dest: globals.yml }
- name: Check whether the Kolla passwords file exists
stat:
path: "{{ kolla_config_path }}/passwords.yml"
register: kolla_passwords_stat
- name: Generate Kolla passwords
shell: >
cp {{ kolla_install_dir }}/etc_examples/kolla/passwords.yml {{ kolla_config_path }}/passwords.yml.generated
&& {{ kolla_venv }}/bin/kolla-genpwd -p {{ kolla_config_path }}/passwords.yml.generated
&& mv {{ kolla_config_path }}/passwords.yml.generated {{ kolla_config_path }}/passwords.yml
become: True
when: not kolla_passwords_stat.stat.exists
- include: config.yml

View File

@ -1,5 +1,12 @@
---
kolla_install_dir: "{{ kolla_venv }}/share/kolla"
# kolla-ansible was bundled with kolla prior to Ocata (4.0.0).
kolla_ansible_is_standalone: "{{ kolla_ansible_source_version | version_compare('4.0.0', '>=') }}"
# Name of the kolla-ansible python module.
kolla_ansible_module: "{% if kolla_ansible_is_standalone | bool %}kolla-ansible{% else %}kolla{% endif %}"
# Path to Kolla Ansible installation directory.
kolla_ansible_install_dir: "{{ kolla_venv }}/share/{{ kolla_ansible_module }}"
# List of features supported by Kolla as enable_* flags.
kolla_feature_flags:

View File

@ -1,6 +1,22 @@
---
# Path to directory for source code checkouts.
source_checkout_path:
# Type of Kolla control installation. One of 'binary' or 'source'.
kolla_ctl_install_type:
# URL of Kolla source code repository if type is 'source'.
kolla_source_url:
# Version (branch, tag, etc.) of Kolla source code repository if type is
# 'source'.
kolla_source_version:
# Virtualenv directory where Kolla will be installed.
kolla_venv: "{{ ansible_env['PWD'] }}/kolla-venv"
# Directory where Kolla config files will be installed.
kolla_config_path:
# Kolla OpenStack release version. This should be a Docker image tag.
kolla_openstack_release:

View File

@ -14,6 +14,13 @@
# 'source'.
#kolla_source_version:
# URL of Kolla Ansible source code repository if type is 'source'.
#kolla_ansible_source_url:
# Version (branch, tag, etc.) of Kolla Ansible source code repository if type
# is 'source'.
#kolla_ansible_source_version:
###############################################################################
# Kolla configuration.
@ -83,6 +90,17 @@
#kolla_enable_vmtp:
#kolla_enable_watcher:
###############################################################################
# Passwords and credentials.
# Dictionary containing default custom passwords to add or override in the
# Kolla passwords file.
#kolla_ansible_default_custom_passwords:
# Dictionary containing custom passwords to add or override in the Kolla
# passwords file.
#kolla_ansible_custom_passwords:
###############################################################################
# Dummy variable to allow Ansible to accept this file.
workaround_ansible_issue_8743: yes