Import the tripleo-persist role from tripleo-common.
The role will now also be tested with Molecule on CentOS 7 and Fedora 28 docker containers. Change-Id: Ic6dfaa56317c68779a50cea63bbf85b9d663184c Signed-off-by: Luke Short <ekultails@gmail.com>
This commit is contained in:
parent
81427894df
commit
7f726d8cf8
6
doc/source/roles/role-tripleo-persist.rst
Normal file
6
doc/source/roles/role-tripleo-persist.rst
Normal file
@ -0,0 +1,6 @@
|
||||
======================================
|
||||
TripleO-Ansible Role - tripleo-persist
|
||||
======================================
|
||||
|
||||
.. ansibleautoplugin::
|
||||
:role: tripleo_ansible/roles/tripleo-persist
|
18
tripleo_ansible/roles/tripleo-persist/defaults/main.yml
Normal file
18
tripleo_ansible/roles/tripleo-persist/defaults/main.yml
Normal file
@ -0,0 +1,18 @@
|
||||
---
|
||||
# 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.
|
||||
|
||||
tripleo_persist_storage_root_dir: /var/lib/mistral/tripleo-persist
|
||||
tripleo_persist_storage_root_become: false
|
@ -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,46 @@
|
||||
---
|
||||
# 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
|
||||
|
||||
vars:
|
||||
tripleo_persist_storage_root_dir: /tmp/tripleo_persist_storage
|
||||
tripleo_persist_dir: /root
|
||||
|
||||
pre_tasks:
|
||||
- name: Create directory
|
||||
file:
|
||||
path: "{{ tripleo_persist_storage_root_dir }}"
|
||||
state: directory
|
||||
mode: 0700
|
||||
|
||||
tasks:
|
||||
- name: Run persist
|
||||
import_role:
|
||||
name: tripleo-persist
|
||||
tasks_from: persist.yml
|
||||
|
||||
- name: Run restore
|
||||
import_role:
|
||||
name: tripleo-persist
|
||||
tasks_from: restore.yml
|
||||
|
||||
- name: Run cleanup
|
||||
import_role:
|
||||
name: tripleo-persist
|
||||
tasks_from: cleanup.yml
|
22
tripleo_ansible/roles/tripleo-persist/tasks/cleanup.yml
Normal file
22
tripleo_ansible/roles/tripleo-persist/tasks/cleanup.yml
Normal file
@ -0,0 +1,22 @@
|
||||
---
|
||||
# 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: ensure tripleo_persist storage directory is removed
|
||||
file:
|
||||
path: "{{ tripleo_persist_storage_root_dir }}"
|
||||
state: absent
|
||||
delegate_to: localhost
|
||||
become: "{{ tripleo_persist_storage_root_become | bool }}"
|
53
tripleo_ansible/roles/tripleo-persist/tasks/persist.yml
Normal file
53
tripleo_ansible/roles/tripleo-persist/tasks/persist.yml
Normal file
@ -0,0 +1,53 @@
|
||||
---
|
||||
# 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: ensure local storage directory exists and has correct permissions
|
||||
file:
|
||||
path: "{{ tripleo_persist_storage_root_dir }}"
|
||||
# Attempting to set an owner fails with "chown failed: failed to
|
||||
# look up user" so we at least ensure the permissions.
|
||||
mode: 0700
|
||||
state: directory
|
||||
delegate_to: localhost
|
||||
become: "{{ tripleo_persist_storage_root_become | bool }}"
|
||||
|
||||
- name: create tempfile for the archive
|
||||
tempfile:
|
||||
prefix: ansible.tripleo-persist.
|
||||
register: tripleo_persist_tempfile
|
||||
|
||||
- name: make sure we don't have a trailing forward slash
|
||||
set_fact:
|
||||
tripleo_persist_dir_safe: "{{ tripleo_persist_dir|regex_replace('\\/$', '') }}"
|
||||
cacheable: false
|
||||
|
||||
# Using the "archive" module lists lists all tarred files in module
|
||||
# output, if there's too many files, it can crash ansible even with
|
||||
# "no_log: true".
|
||||
- name: create the archive
|
||||
shell: |
|
||||
tar -czf "{{ tripleo_persist_tempfile.path }}" -C "{{ tripleo_persist_dir_safe|dirname }}" "{{ tripleo_persist_dir_safe|basename }}"
|
||||
|
||||
- name: fetch the archive
|
||||
fetch:
|
||||
src: "{{ tripleo_persist_tempfile.path }}"
|
||||
dest: "{{ tripleo_persist_storage_root_dir }}/{{ inventory_hostname }}{{ tripleo_persist_dir_safe }}.tar.gz"
|
||||
flat: true
|
||||
|
||||
- name: remove tempfile
|
||||
file:
|
||||
name: "{{ tripleo_persist_tempfile.path }}"
|
||||
state: absent
|
30
tripleo_ansible/roles/tripleo-persist/tasks/restore.yml
Normal file
30
tripleo_ansible/roles/tripleo-persist/tasks/restore.yml
Normal file
@ -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: make sure we don't have a trailing forward slash
|
||||
set_fact:
|
||||
tripleo_persist_dir_safe: "{{ tripleo_persist_dir|regex_replace('\\/$', '') }}"
|
||||
cacheable: false
|
||||
|
||||
- name: make sure the parent directory is present
|
||||
file:
|
||||
path: "{{ tripleo_persist_dir_safe|dirname }}"
|
||||
state: directory
|
||||
|
||||
- name: push and extract the archive
|
||||
unarchive:
|
||||
src: "{{ tripleo_persist_storage_root_dir }}/{{ inventory_hostname }}{{ tripleo_persist_dir_safe }}.tar.gz"
|
||||
dest: "{{ tripleo_persist_dir_safe|dirname }}"
|
@ -17,6 +17,7 @@
|
||||
- tripleo-ansible-centos-7-molecule-tripleo-image-serve
|
||||
- tripleo-ansible-centos-7-molecule-tripleo-transfer
|
||||
- tripleo-ansible-centos-7-molecule-tripleo-podman
|
||||
- tripleo-ansible-centos-7-molecule-tripleo-persist
|
||||
gate:
|
||||
jobs:
|
||||
- tripleo-ansible-centos-7-molecule-aide
|
||||
@ -34,6 +35,7 @@
|
||||
- tripleo-ansible-centos-7-molecule-tripleo-image-serve
|
||||
- tripleo-ansible-centos-7-molecule-tripleo-transfer
|
||||
- tripleo-ansible-centos-7-molecule-tripleo-podman
|
||||
- tripleo-ansible-centos-7-molecule-tripleo-persist
|
||||
name: tripleo-ansible-molecule-jobs
|
||||
- job:
|
||||
files:
|
||||
@ -145,3 +147,10 @@
|
||||
parent: tripleo-ansible-centos-7-base
|
||||
vars:
|
||||
tripleo_role_name: tripleo-podman
|
||||
- job:
|
||||
files:
|
||||
- ^tripleo_ansible/roles/tripleo-persist/.*
|
||||
name: tripleo-ansible-centos-7-molecule-tripleo-persist
|
||||
parent: tripleo-ansible-centos-7-base
|
||||
vars:
|
||||
tripleo_role_name: tripleo-persist
|
||||
|
Loading…
x
Reference in New Issue
Block a user