Create tripleo-cellv2 role
This change introduce tripleo-cellv2 role and playbook create-nova-cell-v2.yaml to simplify the post steps when creating an additional cellv2 in tripleo. For reference, [1] is the doc patch providing at the moment the manual steps. [1] https://review.opendev.org/672744 Change-Id: I288a9217dce948d33d9b47938e7977294d255c7achanges/22/678022/5
parent
bb7bc41730
commit
688ec4c8cd
@ -0,0 +1,6 @@
|
||||
=====================
|
||||
Role - tripleo-cellv2
|
||||
=====================
|
||||
|
||||
.. ansibleautoplugin::
|
||||
:role: tripleo_ansible/roles/tripleo-cellv2
|
@ -0,0 +1,80 @@
|
||||
---
|
||||
# Copyright 2019 Red Hat, Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
- hosts: Controller[0]
|
||||
remote_user: stack
|
||||
gather_facts: true
|
||||
vars:
|
||||
tripleo_cellv2_cell_name: "{{ tripleo_cellv2_cell_name }}"
|
||||
# containercli can be tropped when we fully switched to podman
|
||||
tripleo_cellv2_containercli: "{{ tripleo_cellv2_containercli }}"
|
||||
tripleo_cellv2_cellcontroller_group: "{{ groups['CellController'] }}"
|
||||
tasks:
|
||||
- import_role:
|
||||
name: tripleo-cellv2
|
||||
tasks_from: check_cell_exist.yml
|
||||
|
||||
- hosts: CellController[0]
|
||||
remote_user: stack
|
||||
gather_facts: true
|
||||
vars:
|
||||
tripleo_cellv2_cell_name: "{{ tripleo_cellv2_cell_name }}"
|
||||
# containercli can be tropped when we fully switched to podman
|
||||
tripleo_cellv2_containercli: "{{ tripleo_cellv2_containercli }}"
|
||||
tripleo_cellv2_cellcontroller_group: "{{ groups['CellController'] }}"
|
||||
tasks:
|
||||
- import_role:
|
||||
name: tripleo-cellv2
|
||||
tasks_from: extract_cell_information.yml
|
||||
|
||||
- hosts: Controller[0]
|
||||
remote_user: stack
|
||||
gather_facts: true
|
||||
vars:
|
||||
tripleo_cellv2_cell_name: "{{ tripleo_cellv2_cell_name }}"
|
||||
# containercli can be tropped when we fully switched to podman
|
||||
tripleo_cellv2_containercli: "{{ tripleo_cellv2_containercli }}"
|
||||
tripleo_cellv2_cellcontroller_group: "{{ groups['CellController'] }}"
|
||||
tasks:
|
||||
- import_role:
|
||||
name: tripleo-cellv2
|
||||
tasks_from: create_cell.yml
|
||||
|
||||
- hosts: Controller
|
||||
remote_user: stack
|
||||
gather_facts: true
|
||||
vars:
|
||||
tripleo_cellv2_cell_name: "{{ tripleo_cellv2_cell_name }}"
|
||||
# containercli can be tropped when we fully switched to podman
|
||||
tripleo_cellv2_containercli: "{{ tripleo_cellv2_containercli }}"
|
||||
tripleo_cellv2_cellcontroller_group: "{{ groups['CellController'] }}"
|
||||
tasks:
|
||||
- import_role:
|
||||
name: tripleo-cellv2
|
||||
tasks_from: add_internalapi_hosts_entries.yml
|
||||
|
||||
- hosts: Controller[0]
|
||||
remote_user: stack
|
||||
gather_facts: true
|
||||
vars:
|
||||
tripleo_cellv2_cell_name: "{{ tripleo_cellv2_cell_name }}"
|
||||
# containercli can be tropped when we fully switched to podman
|
||||
tripleo_cellv2_containercli: "{{ tripleo_cellv2_containercli }}"
|
||||
tripleo_cellv2_cellcontroller_group: "{{ groups['CellController'] }}"
|
||||
tasks:
|
||||
- import_role:
|
||||
name: tripleo-cellv2
|
||||
tasks_from: discover_hosts.yml
|
@ -0,0 +1,27 @@
|
||||
---
|
||||
# Copyright 2019 Red Hat, Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
|
||||
# All variables intended for modification should place placed in this file.
|
||||
|
||||
tripleo_cellv2_debug: false
|
||||
tripleo_cellv2_cell_name: ""
|
||||
# containercli can be tropped when we fully switched to podman
|
||||
tripleo_cellv2_containercli: "docker"
|
||||
|
||||
tripleo_cellv2_cellcontroller_group: "{{ groups['CellController'] }}"
|
||||
tripleo_cellv2_cell_database_vip: "{{ hostvars[tripleo_cellv2_cellcontroller_group[0]]['cell_database_vip'] }}"
|
||||
tripleo_cellv2_cell_transport_url: "{{ hostvars[tripleo_cellv2_cellcontroller_group[0]]['cell_transport_url'] }}"
|
@ -0,0 +1,29 @@
|
||||
---
|
||||
# Copyright 2019 Red Hat, Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
- name: nova restart podman
|
||||
systemd:
|
||||
name: "{{ item }}"
|
||||
state: restarted
|
||||
with_items:
|
||||
- tripleo_nova_api
|
||||
- tripleo_nova_conductor
|
||||
- tripleo_nova_scheduler
|
||||
when: containercli == "podman"
|
||||
|
||||
- name: nova restart docker
|
||||
command: docker restart nova_api nova_scheduler nova_conductor
|
||||
when: containercli == "docker"
|
@ -0,0 +1,44 @@
|
||||
---
|
||||
# Copyright 2019 Red Hat, Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
|
||||
galaxy_info:
|
||||
author: OpenStack
|
||||
description: TripleO OpenStack Role -- tripleo-cellv2
|
||||
company: Red Hat
|
||||
license: Apache-2.0
|
||||
min_ansible_version: 2.7
|
||||
#
|
||||
# Provide a list of supported platforms, and for each platform a list of versions.
|
||||
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
|
||||
# To view available platforms and versions (or releases), visit:
|
||||
# https://galaxy.ansible.com/api/v1/platforms/
|
||||
#
|
||||
platforms:
|
||||
- name: Fedora
|
||||
versions:
|
||||
- 28
|
||||
- name: CentOS
|
||||
versions:
|
||||
- 7
|
||||
|
||||
galaxy_tags:
|
||||
- tripleo
|
||||
|
||||
|
||||
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
|
||||
# if you add dependencies to this list.
|
||||
dependencies: []
|
@ -0,0 +1,37 @@
|
||||
# Molecule managed
|
||||
# Copyright 2019 Red Hat, Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
|
||||
{% if item.registry is defined %}
|
||||
FROM {{ item.registry.url }}/{{ item.image }}
|
||||
{% else %}
|
||||
FROM {{ item.image }}
|
||||
{% endif %}
|
||||
|
||||
RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates && apt-get clean; \
|
||||
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python*-dnf bash {{ item.pkg_extras | default('') }} && dnf clean all; \
|
||||
elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl python-setuptools bash {{ item.pkg_extras | default('') }} && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
|
||||
elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml {{ item.pkg_extras | default('') }} && zypper clean -a; \
|
||||
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates {{ item.pkg_extras | default('') }}; \
|
||||
elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates {{ item.pkg_extras | default('') }} && xbps-remove -O; fi
|
||||
|
||||
{% for pkg in item.easy_install | default([]) %}
|
||||
# install pip for centos where there is no python-pip rpm in default repos
|
||||
RUN easy_install {{ pkg }}
|
||||
{% endfor %}
|
||||
|
||||
|
||||
CMD ["sh", "-c", "while true; do sleep 10000; done"]
|
@ -0,0 +1,48 @@
|
||||
---
|
||||
driver:
|
||||
name: docker
|
||||
|
||||
log: true
|
||||
|
||||
platforms:
|
||||
- name: centos7
|
||||
hostname: centos7
|
||||
image: centos:7
|
||||
dockerfile: Dockerfile
|
||||
pkg_extras: python-setuptools
|
||||
easy_install:
|
||||
- pip
|
||||
environment: &env
|
||||
http_proxy: "{{ lookup('env', 'http_proxy') }}"
|
||||
https_proxy: "{{ lookup('env', 'https_proxy') }}"
|
||||
|
||||
- name: fedora28
|
||||
hostname: fedora28
|
||||
image: fedora:28
|
||||
dockerfile: Dockerfile
|
||||
pkg_extras: python*-setuptools
|
||||
environment:
|
||||
<<: *env
|
||||
|
||||
provisioner:
|
||||
name: ansible
|
||||
log: true
|
||||
env:
|
||||
ANSIBLE_STDOUT_CALLBACK: yaml
|
||||
|
||||
scenario:
|
||||
test_sequence:
|
||||
- destroy
|
||||
- create
|
||||
- prepare
|
||||
- converge
|
||||
- verify
|
||||
- destroy
|
||||
|
||||
lint:
|
||||
enabled: false
|
||||
|
||||
verifier:
|
||||
name: testinfra
|
||||
lint:
|
||||
name: flake8
|
@ -0,0 +1,21 @@
|
||||
---
|
||||
# Copyright 2019 Red Hat, Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
|
||||
- name: Converge
|
||||
hosts: all
|
||||
roles:
|
||||
- role: "tripleo-cellv2"
|
@ -0,0 +1,21 @@
|
||||
---
|
||||
# Copyright 2019 Red Hat, Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
|
||||
- name: Prepare
|
||||
hosts: all
|
||||
roles:
|
||||
- role: test_deps
|
@ -0,0 +1,38 @@
|
||||
---
|
||||
# Copyright 2019 Red Hat, Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
- name: Add CellController internalapi to control plan controller
|
||||
become: true
|
||||
lineinfile:
|
||||
dest: "/etc/hosts"
|
||||
regexp: ".*{{ hostvars[item]['internal_api_hostname'] }}.*$"
|
||||
line: >-
|
||||
{{ hostvars[item]['internal_api_ip'] }}
|
||||
{{ hostvars[item]['internal_api_hostname'] }}
|
||||
{{ hostvars[item]['internal_api_hostname'].split('.')[:2] | join('.') }}
|
||||
insertafter: "# HEAT_HOSTS_END"
|
||||
state: present
|
||||
when:
|
||||
- hostvars[item]['internal_api_ip'] is defined
|
||||
- hostvars[item]['internal_api_hostname'] is defined
|
||||
with_items: "{{ tripleo_cellv2_cellcontroller_group }}"
|
||||
register: hosts_result
|
||||
notify:
|
||||
- nova restart podman
|
||||
- nova restart docker
|
||||
tags:
|
||||
- hosts
|
||||
- create
|
@ -0,0 +1,37 @@
|
||||
---
|
||||
# Copyright 2019 Red Hat, Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
- name: Check if cell exist
|
||||
block:
|
||||
- name: Fail if cell_name or containercli are not passed
|
||||
fail: msg="Both tripleo_cellv2_cell_name and tripleo_cellv2_containercli are mandatory parameters!"
|
||||
when: tripleo_cellv2_cell_name is not defined or tripleo_cellv2_containercli is not defined
|
||||
- name: Check if cell is already created
|
||||
become: true
|
||||
shell: |-
|
||||
set -o pipefail
|
||||
{{ tripleo_cellv2_containercli }} exec -i -u root nova_api \
|
||||
nova-manage {{ (tripleo_cellv2_debug | bool) | ternary('--debug', '') }} \
|
||||
cell_v2 list_cells | grep {{ tripleo_cellv2_cell_name }}
|
||||
ignore_errors: true
|
||||
register: cell_check_result
|
||||
- name: Fail if cell already exist
|
||||
fail: msg="Cell with name {{ tripleo_cellv2_cell_name }} already exist!"
|
||||
when: cell_check_result.rc == 0
|
||||
tags:
|
||||
- check
|
||||
- extract
|
||||
- create
|
@ -0,0 +1,35 @@
|
||||
---
|
||||
# Copyright 2019 Red Hat, Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
- name: Create new Cell
|
||||
become: true
|
||||
block:
|
||||
- name: Create Cell
|
||||
shell: >-
|
||||
{{ tripleo_cellv2_containercli }} exec -i -u root nova_api
|
||||
nova-manage cell_v2 create_cell --name {{ tripleo_cellv2_cell_name }}
|
||||
--database_connection "{scheme}://{username}:{password}@{{ tripleo_cellv2_cell_database_vip }}/nova?{query}"
|
||||
--transport-url "{{ tripleo_cellv2_cell_transport_url }}"
|
||||
|
||||
- name: List Cells
|
||||
shell: >
|
||||
{{ tripleo_cellv2_containercli }} exec -i -u root nova_api
|
||||
nova-manage cell_v2 list_cells
|
||||
register: cells
|
||||
|
||||
- debug: var=cells.stdout_lines
|
||||
tags:
|
||||
- create
|
@ -0,0 +1,30 @@
|
||||
---
|
||||
# Copyright 2019 Red Hat, Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
- name: Discover cell nodes
|
||||
become: true
|
||||
block:
|
||||
- name: Discover hosts
|
||||
shell: >-
|
||||
{{ tripleo_cellv2_containercli }} exec -i -u root nova_api
|
||||
nova-manage cell_v2 discover_hosts --by-service --verbose
|
||||
|
||||
- name: List Cells
|
||||
shell: >-
|
||||
{{ tripleo_cellv2_containercli }} exec -i -u root nova_api
|
||||
nova-manage cell_v2 list_cells
|
||||
tags:
|
||||
- discover
|
@ -0,0 +1,39 @@
|
||||
---
|
||||
# Copyright 2019 Red Hat, Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
- name: Extract transport_url and database connection from one CellController
|
||||
become: true
|
||||
block:
|
||||
- name: Extract transport_url from CellController
|
||||
command: >-
|
||||
crudini --get /var/lib/config-data/nova/etc/nova/nova.conf DEFAULT transport_url
|
||||
register: cell_transport_url_result
|
||||
|
||||
- name: Set fact cell_transport_url
|
||||
set_fact:
|
||||
cell_transport_url: "{{ cell_transport_url_result.stdout }}"
|
||||
|
||||
- name: Extract database connection from CellController
|
||||
command: >-
|
||||
crudini --get /var/lib/config-data/nova/etc/nova/nova.conf database connection
|
||||
register: cell_database_vip_result
|
||||
|
||||
- name: Set fact cell_database_vip
|
||||
set_fact:
|
||||
cell_database_vip: "{{ cell_database_vip_result.stdout |regex_replace('.*@(.*?)/.*$', '\\1') }}"
|
||||
tags:
|
||||
- extract
|
||||
- create
|
Loading…
Reference in New Issue