Import the tripleo-docker-rm role

The docker-rm role is a duplicate role from tripleo-common which provides
for the same things as the tripleo-container-rm. To ensure we're
developing a consistent user experience the docker-rm role was created
as a symlink to container-rm.

The container-rm role was updated drive consistency across roles by
changing the default "container_cli". Now all roles with the container_cli
variable will have the same default.

Because this role is a symlink no new zuul tests were added for this role.
The interface will be exercised via a new scenario in the container-rm role.

Change-Id: I33ecf735af5c5b0a9a0a9f0c650fc2a04f0864a2
Signed-off-by: Kevin Carter <kecarter@redhat.com>
This commit is contained in:
Kevin Carter 2019-06-21 18:40:30 -05:00
parent 1db5553f09
commit 2135446a35
15 changed files with 228 additions and 111 deletions

View File

@ -1,6 +1,6 @@
===========================================
TripleO-Ansible Role - tripleo-container-rm
===========================================
===========================
Role - tripleo-container-rm
===========================
This role provides for the following services:
@ -26,6 +26,6 @@ Example default playbook
Example docker playbook
~~~~~~~~~~~~~~~~~~~~~~~
.. literalinclude:: ../../../tripleo_ansible/roles/tripleo-container-rm/molecule/docker/playbook.yml
.. literalinclude:: ../../../tripleo_ansible/roles/tripleo-container-rm/molecule/podman/playbook.yml
:language: yaml
:start-after: under the License.

View File

@ -0,0 +1,31 @@
========================
Role - tripleo-docker-rm
========================
This role provides for the following services:
* tripleo-docker-rm
.. DANGER::
This role is a linked role to `tripleo-container-rm`. This role and exists
to ensure we're providing a stable interface as we transition. In a future
release this link will be removed in favor of using the stable role,
`tripleo-container-rm`.
Default variables
~~~~~~~~~~~~~~~~~
.. literalinclude:: ../../../tripleo_ansible/roles/tripleo-docker-rm/defaults/main.yml
:language: yaml
:start-after: under the License.
Example playbook
~~~~~~~~~~~~~~~~
.. literalinclude:: ../../../tripleo_ansible/roles/tripleo-docker-rm/molecule/docker_rm/playbook.yml
:language: yaml
:start-after: under the License.

View File

@ -274,3 +274,9 @@ basepython = {[testenv:mol]basepython}
deps = {[testenv:mol]deps}
changedir = {toxinidir}/tripleo_ansible/roles/tripleo-container-rm
commands = python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py --scenario=docker
[testenv:mol-tripleo-container-rm-docker_rm]
basepython = {[testenv:mol]basepython}
deps = {[testenv:mol]deps}
changedir = {toxinidir}/tripleo_ansible/roles/tripleo-container-rm
commands = python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py --scenario=docker_rm

View File

@ -26,7 +26,7 @@
# is no longer in use.
#
# Set the container command line entry-point
tripleo_container_cli: "{{ container_cli | default('podman') }}"
tripleo_container_cli: "{{ container_cli | default('docker') }}"
# List of containers to delete
tripleo_containers_to_rm: "{{ containers_to_rm | default([]) }}"

View File

@ -20,6 +20,10 @@
hosts: all
roles:
- role: tripleo-container-rm
containers_to_rm:
- podman-container1
- podman-container2
tripleo_containers_to_rm:
- docker-container1
- docker-container2
tripleo_container_cli: docker
vars:
ansible_python_interpreter: /opt/tripleo-ansible/bin/python

View File

@ -23,21 +23,62 @@
gather_facts: true
vars:
required_packages:
- podman
- docker
- python-docker-py
- python-virtualenv
pre_tasks:
- name: Set current user fact
set_fact:
current_user: "{{ lookup('env','USER') }}"
roles:
- role: test_deps
post_tasks:
- name: Install podman
become: true
package:
name: "{{ required_packages }}"
state: latest
- name: Docker block
block:
- name: Install docker
package:
name: "{{ required_packages }}"
state: latest
- name: Pull container image
command: "podman pull fedora:28"
- name: Ensure "docker" group exists
group:
name: docker
state: present
- name: Create test containers
command: "podman run -itd --systemd --name {{ item }} fedora bash"
- name: Ensure the ansible user can access docker
user:
name: "{{ ansible_user | default(current_user) }}"
groups: docker
- name: Start docker
systemd:
name: docker
state: started
- name: Install python-docker in venv
pip:
name: "docker"
virtualenv: /opt/tripleo-ansible
virtualenv_site_packages: true
- name: reset ssh connection to allow user changes to take affect
meta: reset_connection
- name: pull an image
vars:
ansible_python_interpreter: /opt/tripleo-ansible/bin/python
docker_image:
name: fedora:28
source: pull
- name: Create a data container
vars:
ansible_python_interpreter: /opt/tripleo-ansible/bin/python
docker_container:
name: "{{ item }}"
image: fedora:28
detach: true
command: sleep 1d
with_items:
- podman-container1
- podman-container2
- docker-container1
- docker-container2

View File

@ -1,84 +0,0 @@
---
# 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.
- import_playbook: ../pre-prepare.yml
- name: Prepare
hosts: all
become: true
gather_facts: true
vars:
required_packages:
- docker
- python-docker-py
- python-virtualenv
pre_tasks:
- name: Set current user fact
set_fact:
current_user: "{{ lookup('env','USER') }}"
roles:
- role: test_deps
post_tasks:
- name: Docker block
block:
- name: Install docker
package:
name: "{{ required_packages }}"
state: latest
- name: Ensure "docker" group exists
group:
name: docker
state: present
- name: Ensure the ansible user can access docker
user:
name: "{{ ansible_user | default(current_user) }}"
groups: docker
- name: Start docker
systemd:
name: docker
state: started
- name: Install python-docker in venv
pip:
name: "docker"
virtualenv: /opt/tripleo-ansible
virtualenv_site_packages: true
- name: reset ssh connection to allow user changes to take affect
meta: reset_connection
- name: pull an image
vars:
ansible_python_interpreter: /opt/tripleo-ansible/bin/python
docker_image:
name: fedora:28
source: pull
- name: Create a data container
vars:
ansible_python_interpreter: /opt/tripleo-ansible/bin/python
docker_container:
name: "{{ item }}"
image: fedora:28
detach: true
command: sleep 1d
with_items:
- docker-container1
- docker-container2

View 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.
# NOTE(Cloudnull): This role is a linked role to `tripleo-container-rm`. This role and exists
# to ensure we're providing a stable interface as we transition. In a future
# release this link will be removed in favor of using the stable role,
# `tripleo-container-rm`.
- name: Converge
become: true
hosts: all
roles:
- role: tripleo-docker-rm
container_cli: docker
containers_to_rm:
- docker-container1
- docker-container2

View File

@ -0,0 +1 @@
../default/prepare.yml

View File

@ -0,0 +1,48 @@
---
driver:
name: delegated
options:
managed: false
login_cmd_template: >-
ssh
-o UserKnownHostsFile=/dev/null
-o StrictHostKeyChecking=no
-o Compression=no
-o TCPKeepAlive=yes
-o VerifyHostKeyDNS=no
-o ForwardX11=no
-o ForwardAgent=no
{instance}
ansible_connection_options:
ansible_connection: ssh
log: true
platforms:
- name: instance
provisioner:
name: ansible
inventory:
hosts:
all:
hosts:
instance:
ansible_host: localhost
log: true
env:
ANSIBLE_STDOUT_CALLBACK: yaml
scenario:
test_sequence:
- prepare
- converge
- verify
lint:
enabled: false
verifier:
name: testinfra
lint:
name: flake8

View File

@ -20,10 +20,6 @@
hosts: all
roles:
- role: tripleo-container-rm
tripleo_containers_to_rm:
- docker-container1
- docker-container2
tripleo_container_cli: docker
vars:
ansible_python_interpreter: /opt/tripleo-ansible/bin/python
containers_to_rm:
- podman-container1
- podman-container2

View File

@ -0,0 +1,43 @@
---
# 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.
- import_playbook: ../pre-prepare.yml
- name: Prepare
hosts: all
become: true
gather_facts: true
vars:
required_packages:
- podman
roles:
- role: test_deps
post_tasks:
- name: Install podman
become: true
package:
name: "{{ required_packages }}"
state: latest
- name: Pull container image
command: "podman pull fedora:28"
- name: Create test containers
command: "podman run -itd --systemd --name {{ item }} fedora bash"
with_items:
- podman-container1
- podman-container2

View File

@ -0,0 +1 @@
tripleo-container-rm