mirror of
https://github.com/containers/ansible-podman-collections.git
synced 2026-02-04 07:11:49 +00:00
Set up testing for podman connection
This commit is contained in:
parent
65b6f5b278
commit
f79f36fd38
32 changed files with 563 additions and 109 deletions
|
|
@ -1,10 +1,8 @@
|
|||
name: Collection test suite
|
||||
name: Collection build and tests
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
schedule:
|
||||
- cron: 3 0 * * * # Run daily at 0:03 UTC
|
||||
|
||||
jobs:
|
||||
build-collection-artifact:
|
||||
|
|
@ -18,8 +16,6 @@ jobs:
|
|||
- git+https://github.com/ansible/ansible.git@devel
|
||||
runner-python-version:
|
||||
- 3.7
|
||||
|
||||
|
||||
steps:
|
||||
- name: Check out ${{ github.repository }} on disk
|
||||
uses: actions/checkout@master
|
||||
|
|
@ -97,4 +93,4 @@ jobs:
|
|||
working-directory: >-
|
||||
/home/runner/.ansible/collections/ansible_collections/containers/podman
|
||||
|
||||
# When we have unit tests, add them here
|
||||
# When we have unit tests, add them here
|
||||
|
|
|
|||
237
.github/workflows/connections_tests.yml
vendored
Normal file
237
.github/workflows/connections_tests.yml
vendored
Normal file
|
|
@ -0,0 +1,237 @@
|
|||
name: Test connection plugins
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '.github/workflows/*'
|
||||
- 'ci/**'
|
||||
- 'plugins/connection/**'
|
||||
- 'tests/integration/targets/connection/**'
|
||||
- 'tests/integration/targets/connection_*/**'
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
paths:
|
||||
- '.github/workflows/*'
|
||||
- 'ci/**'
|
||||
- 'plugins/connection/**'
|
||||
- 'tests/integration/targets/connection/**'
|
||||
- 'tests/integration/targets/connection_*/**'
|
||||
schedule:
|
||||
- cron: 3 0 * * * # Run daily at 0:03 UTC
|
||||
|
||||
jobs:
|
||||
build-collection-artifact-connection-tests:
|
||||
name: Build artifact
|
||||
runs-on: ${{ matrix.runner-os }}
|
||||
strategy:
|
||||
matrix:
|
||||
runner-os:
|
||||
- ubuntu-16.04
|
||||
ansible-version:
|
||||
- git+https://github.com/ansible/ansible.git@devel
|
||||
runner-python-version:
|
||||
- 3.7
|
||||
steps:
|
||||
- name: Check out ${{ github.repository }} on disk
|
||||
uses: actions/checkout@master
|
||||
- name: Set up Python ${{ matrix.runner-python-version }}
|
||||
uses: actions/setup-python@v1
|
||||
with:
|
||||
python-version: ${{ matrix.runner-python-version }}
|
||||
- name: Set up pip cache
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: ~/.cache/pip
|
||||
key: ${{ runner.os }}-pip-${{ hashFiles('tests/sanity/requirements.txt') }}-${{ hashFiles('tests/unit/requirements.txt') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pip-
|
||||
${{ runner.os }}-
|
||||
- name: Install Ansible ${{ matrix.ansible-version }}
|
||||
run: >-
|
||||
python -m pip install --user '${{ matrix.ansible-version }}'
|
||||
- name: Build a collection tarball
|
||||
run: >-
|
||||
~/.local/bin/ansible-galaxy collection build --output-path
|
||||
"${GITHUB_WORKSPACE}/.cache/collection-tarballs"
|
||||
- name: Store migrated collection artifacts
|
||||
uses: actions/upload-artifact@v1
|
||||
with:
|
||||
name: collection
|
||||
path: .cache/collection-tarballs
|
||||
|
||||
test-podman-connection:
|
||||
name: Podman connection VM ${{ matrix.os.vm || 'ubuntu-latest' }}-${{ matrix.ansible-version }}
|
||||
needs:
|
||||
- build-collection-artifact-connection-tests
|
||||
runs-on: ${{ matrix.os.vm || 'ubuntu-latest' }}
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
ansible-version:
|
||||
- ansible<2.10
|
||||
- git+https://github.com/ansible/ansible.git@devel
|
||||
os:
|
||||
- vm: ubuntu-latest
|
||||
#- vm: ubuntu-16.04
|
||||
#- vm: macos-latest
|
||||
python-version:
|
||||
#- 3.8
|
||||
- 3.7
|
||||
#- 3.6
|
||||
#- 3.5
|
||||
#- 2.7
|
||||
steps:
|
||||
|
||||
- name: Check out repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
|
||||
- name: Upgrade pip and display Python and PIP versions
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
python -V
|
||||
pip --version
|
||||
|
||||
- name: Set up pip cache
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: ~/.cache/pip
|
||||
key: ${{ runner.os }}-pip-${{ github.ref }}-units-VMs
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pip-
|
||||
${{ runner.os }}-
|
||||
|
||||
- name: Install Ansible ${{ matrix.ansible-version }}
|
||||
run: python -m pip install --user '${{ matrix.ansible-version }}'
|
||||
|
||||
- name: Download migrated collection artifacts
|
||||
uses: actions/download-artifact@v1
|
||||
with:
|
||||
name: collection
|
||||
path: .cache/collection-tarballs
|
||||
|
||||
- name: Install the collection tarball
|
||||
run: >-
|
||||
~/.local/bin/ansible-galaxy collection install .cache/collection-tarballs/*.tar.gz
|
||||
|
||||
- name: Run collection tests for connection
|
||||
run: |
|
||||
export PATH=~/.local/bin:$PATH
|
||||
|
||||
if [[ '${{ matrix.ansible-version }}' == 'git+https://github.com/ansible/ansible.git@devel' ]]; then
|
||||
export ANSIBLE_CONFIG=$(pwd)/ci/ansible-dev.cfg
|
||||
elif [[ '${{ matrix.ansible-version }}' == 'ansible<2.10' ]]; then
|
||||
export ANSIBLE_CONFIG=$(pwd)/ci/ansible-2.9.cfg
|
||||
fi
|
||||
|
||||
echo $ANSIBLE_CONFIG
|
||||
command -v ansible-playbook
|
||||
pip --version
|
||||
python --version
|
||||
ansible-playbook --version
|
||||
|
||||
ansible-playbook -vv ci/playbooks/pre.yml \
|
||||
-e host=localhost \
|
||||
-i localhost, \
|
||||
-e ansible_connection=local \
|
||||
-e setup_python=false
|
||||
|
||||
ROOT= ./ci/run_connection_test.sh podman
|
||||
ROOT=true ./ci/run_connection_test.sh podman
|
||||
shell: bash
|
||||
|
||||
test-buildah-connection:
|
||||
name: Buildah connection VM ${{ matrix.os.vm || 'ubuntu-latest' }}-${{ matrix.ansible-version }}
|
||||
needs:
|
||||
- build-collection-artifact-connection-tests
|
||||
runs-on: ${{ matrix.os.vm || 'ubuntu-latest' }}
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
ansible-version:
|
||||
- ansible<2.10
|
||||
- git+https://github.com/ansible/ansible.git@devel
|
||||
os:
|
||||
- vm: ubuntu-latest
|
||||
#- vm: ubuntu-16.04
|
||||
#- vm: macos-latest
|
||||
python-version:
|
||||
#- 3.8
|
||||
- 3.7
|
||||
#- 3.6
|
||||
#- 3.5
|
||||
#- 2.7
|
||||
steps:
|
||||
|
||||
- name: Check out repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
|
||||
- name: Upgrade pip and display Python and PIP versions
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
python -V
|
||||
pip --version
|
||||
|
||||
- name: Set up pip cache
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: ~/.cache/pip
|
||||
key: ${{ runner.os }}-pip-${{ github.ref }}-units-VMs
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pip-
|
||||
${{ runner.os }}-
|
||||
|
||||
- name: Install Ansible ${{ matrix.ansible-version }}
|
||||
run: python -m pip install --user '${{ matrix.ansible-version }}'
|
||||
|
||||
- name: Download migrated collection artifacts
|
||||
uses: actions/download-artifact@v1
|
||||
with:
|
||||
name: collection
|
||||
path: .cache/collection-tarballs
|
||||
|
||||
- name: Install the collection tarball
|
||||
run: >-
|
||||
~/.local/bin/ansible-galaxy collection install .cache/collection-tarballs/*.tar.gz
|
||||
|
||||
- name: Run collection tests for connection
|
||||
run: |
|
||||
export PATH=~/.local/bin:$PATH
|
||||
|
||||
if [[ '${{ matrix.ansible-version }}' == 'git+https://github.com/ansible/ansible.git@devel' ]]; then
|
||||
export ANSIBLE_CONFIG=$(pwd)/ci/ansible-dev.cfg
|
||||
elif [[ '${{ matrix.ansible-version }}' == 'ansible<2.10' ]]; then
|
||||
export ANSIBLE_CONFIG=$(pwd)/ci/ansible-2.9.cfg
|
||||
fi
|
||||
|
||||
echo $ANSIBLE_CONFIG
|
||||
command -v ansible-playbook
|
||||
pip --version
|
||||
python --version
|
||||
ansible-playbook --version
|
||||
|
||||
ansible-playbook -vv ci/playbooks/pre.yml \
|
||||
-e host=localhost \
|
||||
-i localhost, \
|
||||
-e ansible_connection=local \
|
||||
-e setup_python=false
|
||||
|
||||
ROOT=true ./ci/run_connection_test.sh buildah
|
||||
# ROOT= ./ci/run_connection_test.sh buildah # not supported yet
|
||||
shell: bash
|
||||
4
ci/ansible-2.9.cfg
Normal file
4
ci/ansible-2.9.cfg
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
[defaults]
|
||||
bin_ansible_callbacks = True
|
||||
stdout_callback = debug
|
||||
force_color = True
|
||||
2
ci/ansible-dev.cfg
Normal file
2
ci/ansible-dev.cfg
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
[defaults]
|
||||
force_color = True
|
||||
73
ci/playbooks/build.yml
Normal file
73
ci/playbooks/build.yml
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
- hosts: "{{ host|default('all') }}"
|
||||
gather_facts: true
|
||||
vars:
|
||||
repo_url: https://github.com/containers/ansible-podman-collections.git
|
||||
repo_dir: "/home/{{ ansible_user }}/ansible-podman-collections"
|
||||
temp_collect: /tmp/collection
|
||||
distro: "{{ ansible_distribution }}{{ ansible_distribution_major_version }}"
|
||||
tasks:
|
||||
|
||||
- name: Set PR vars if defined
|
||||
set_fact:
|
||||
pr_branch: "pull/{{ pr }}/head"
|
||||
pr_refspec: "refs/pull/{{ pr }}/head:refs/remotes/origin/pull/{{ pr }}/head"
|
||||
when: pr is defined
|
||||
|
||||
- name: Clone collection
|
||||
git:
|
||||
dest: "{{ repo_dir }}"
|
||||
repo: "{{ repo_url }}"
|
||||
version: "{{ pr_branch|default('master') }}"
|
||||
refspec: "{{ pr_refspec|default(omit) }}"
|
||||
force: true
|
||||
register: git_clone
|
||||
ignore_errors: true
|
||||
when: clone_repo|default(true)|bool
|
||||
|
||||
# https://github.com/ansible/ansible/issues/67972
|
||||
- name: Update manually if need
|
||||
command: git fetch -f -u origin {{ pr_branch }}:{{ pr_branch }}
|
||||
args:
|
||||
chdir: "{{ repo_dir }}"
|
||||
when:
|
||||
- git_clone is failed
|
||||
- pr is defined
|
||||
|
||||
- name: Remove temporary collection dir
|
||||
file:
|
||||
path: "{{ temp_collect }}"
|
||||
state: absent
|
||||
|
||||
- name: Create temporary collection dir
|
||||
file:
|
||||
path: "{{ temp_collect }}"
|
||||
state: directory
|
||||
|
||||
- name: Build collection
|
||||
shell: >-
|
||||
{% if ansible_venv is defined %}source {{ ansible_venv }}/bin/activate;{% endif %}
|
||||
ansible-galaxy collection build --output-path {{ temp_collect }} --force
|
||||
args:
|
||||
chdir: "{{ repo_dir }}"
|
||||
|
||||
- name: Find a path of collection file
|
||||
find:
|
||||
paths: "{{ temp_collect }}/"
|
||||
patterns: "*tar.gz"
|
||||
register: file_path
|
||||
|
||||
- name: Install collection
|
||||
become: "{{ distro == 'CentOS7' }}"
|
||||
shell: >-
|
||||
{% if ansible_venv is defined %}source {{ ansible_venv }}/bin/activate;{% endif %}
|
||||
ansible-galaxy collection install {{ file_path.files.0.path }} --force
|
||||
args:
|
||||
chdir: "{{ repo_dir }}"
|
||||
|
||||
- name: Install collection for root
|
||||
become: true
|
||||
shell: >-
|
||||
{% if ansible_venv is defined %}source {{ ansible_venv }}/bin/activate;{% endif %}
|
||||
ansible-galaxy collection install {{ file_path.files.0.path }} --force
|
||||
args:
|
||||
chdir: "{{ repo_dir }}"
|
||||
14
ci/playbooks/connection_test.yml
Normal file
14
ci/playbooks/connection_test.yml
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
---
|
||||
- hosts: "{{ host|default('all') }}"
|
||||
gather_facts: true
|
||||
vars:
|
||||
repo_dir: "/home/{{ ansible_user }}/ansible-podman-collections"
|
||||
distro: "{{ ansible_distribution }}{{ ansible_distribution_major_version }}"
|
||||
tasks:
|
||||
|
||||
- name: Run test script
|
||||
become: "{{ distro == 'CentOS7' }}"
|
||||
shell: >-
|
||||
{% if ansible_venv is defined %}source {{ ansible_venv }}/bin/activate; {% endif %}
|
||||
|
||||
{{ repo_dir }}/ci/run_connection_test.sh
|
||||
19
ci/playbooks/connections/test.yml
Normal file
19
ci/playbooks/connections/test.yml
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
---
|
||||
- hosts: "{{ host|default('all') }}"
|
||||
connection: "{{ connection_type }}"
|
||||
tasks:
|
||||
|
||||
- name: Copy file
|
||||
copy:
|
||||
src: /tmp/local_file
|
||||
dest: ~/
|
||||
|
||||
- name: Copy file from container
|
||||
fetch:
|
||||
src: ~/local_file
|
||||
dest: /tmp/remote_file
|
||||
flat: true
|
||||
|
||||
- name: Compare test files
|
||||
shell: diff -q /tmp/local_file /tmp/remote_file
|
||||
delegate_to: localhost
|
||||
9
ci/playbooks/install_repos.yml
Normal file
9
ci/playbooks/install_repos.yml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
---
|
||||
- name: Install repo for ubuntu
|
||||
become: true
|
||||
shell: |
|
||||
. /etc/os-release
|
||||
echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/ /" > /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
|
||||
curl -L https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/Release.key | apt-key add -
|
||||
apt-get update
|
||||
when: ansible_distribution|lower == "ubuntu"
|
||||
18
ci/playbooks/local.yml
Normal file
18
ci/playbooks/local.yml
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
---
|
||||
- include: pre.yml
|
||||
vars:
|
||||
host: localhost
|
||||
ansible_venv: /tmp/ansible-test
|
||||
ansible_venv_site_packages: true
|
||||
clean_venv: true
|
||||
|
||||
- include: build.yml
|
||||
vars:
|
||||
host: localhost
|
||||
repo_dir: "{{ source | default('/tmp/ansible-podman-collections-test') }}"
|
||||
clone_repo: "{{ source is not defined }}"
|
||||
|
||||
- include: connection_test.yml
|
||||
vars:
|
||||
host: localhost
|
||||
repo_dir: "{{ source | default('/tmp/ansible-podman-collections-test') }}"
|
||||
87
ci/playbooks/pre.yml
Normal file
87
ci/playbooks/pre.yml
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
---
|
||||
- hosts: "{{ host|default('all') }}"
|
||||
gather_facts: true
|
||||
vars:
|
||||
ansible_pip_version: '<2.10'
|
||||
distro: "{{ ansible_distribution }}{{ ansible_distribution_major_version }}"
|
||||
tasks:
|
||||
|
||||
- become: true
|
||||
block:
|
||||
|
||||
- name: Install Python3 and pip
|
||||
package:
|
||||
name:
|
||||
- python3
|
||||
- python3-pip
|
||||
when:
|
||||
- distro != 'CentOS7'
|
||||
- setup_python|default(true)|bool
|
||||
|
||||
- name: Install EPEL for CentOS 7
|
||||
package:
|
||||
name:
|
||||
- epel-release
|
||||
when:
|
||||
- distro == 'CentOS7'
|
||||
- setup_python|default(true)|bool
|
||||
|
||||
- name: Install Python and pip for CentOS 7
|
||||
package:
|
||||
name:
|
||||
- python
|
||||
- python-pip
|
||||
when:
|
||||
- distro == 'CentOS7'
|
||||
- setup_python|default(true)|bool
|
||||
|
||||
- name: Upgrade pip
|
||||
pip:
|
||||
name: pip
|
||||
extra_args: --upgrade
|
||||
|
||||
- name: Install virtualenv
|
||||
pip:
|
||||
name:
|
||||
- virtualenv
|
||||
when: ansible_venv is defined
|
||||
|
||||
- name: Remove virtualenv if need
|
||||
file:
|
||||
path: "{{ ansible_venv }}"
|
||||
state: absent
|
||||
when:
|
||||
- clean_venv|default(false)|bool
|
||||
- ansible_venv is defined
|
||||
|
||||
- name: Install ansible
|
||||
pip:
|
||||
name: ansible
|
||||
version: "{{ ansible_pip_version }}"
|
||||
extra_args: --upgrade
|
||||
virtualenv: "{{ ansible_venv|default(omit) }}"
|
||||
virtualenv_site_packages: "{{ ansible_venv_site_packages|default(omit) }}"
|
||||
environment:
|
||||
PATH: /usr/local/bin:{{ ansible_env.PATH }}
|
||||
when:
|
||||
- ansible_venv is defined
|
||||
|
||||
- name: Install repositories if need
|
||||
include_tasks: install_repos.yml
|
||||
|
||||
- name: Install podman
|
||||
package:
|
||||
name:
|
||||
- podman
|
||||
- buildah
|
||||
- git
|
||||
- vim
|
||||
|
||||
- name: Get podman version
|
||||
shell: |
|
||||
podman version
|
||||
buildah version
|
||||
podman info --debug
|
||||
buildah info --debug
|
||||
conmon --version
|
||||
runc --version
|
||||
42
ci/run_connection_test.sh
Executable file
42
ci/run_connection_test.sh
Executable file
|
|
@ -0,0 +1,42 @@
|
|||
#!/bin/bash
|
||||
set -o pipefail
|
||||
set -eux
|
||||
|
||||
CON_TYPE="${1:-podman}"
|
||||
SUDO=${ROOT:+"sudo -E"}
|
||||
|
||||
ANSIBLECMD=$(command -v ansible-playbook)
|
||||
echo "Testing $CON_TYPE connection ${ROOT:+'with root'}"
|
||||
|
||||
if [[ "$CON_TYPE" == "podman" ]]; then
|
||||
${SUDO} podman ps | grep -q "${CON_TYPE}-container" || \
|
||||
${SUDO} podman run -d --rm --name "${CON_TYPE}-container" python:3-alpine sleep 1d
|
||||
elif [[ "$CON_TYPE" == "buildah" ]]; then
|
||||
${SUDO} buildah from --name=buildah-container python:2
|
||||
fi
|
||||
|
||||
pushd "tests/integration/targets/connection_${CON_TYPE}"
|
||||
ANSIBLECMD=${ANSIBLECMD} SUDO="${SUDO}" ./runme.sh
|
||||
popd
|
||||
|
||||
# Create a big file for uploading to container
|
||||
[[ ! -f /tmp/local_file ]] && head -c 5M </dev/urandom >/tmp/local_file
|
||||
|
||||
exit_code=0
|
||||
CMD="${SUDO:-} ${ANSIBLECMD:-ansible-playbook} \
|
||||
-i tests/integration/targets/connection_${CON_TYPE}/test_connection.inventory \
|
||||
-e connection_type=containers.podman.${CON_TYPE} \
|
||||
ci/playbooks/connections/test.yml"
|
||||
$CMD -vv || exit_code=$?
|
||||
|
||||
if [[ "$exit_code" != 0 ]]; then
|
||||
$CMD -vvvvv
|
||||
fi
|
||||
|
||||
# Clean up
|
||||
if [[ "$CON_TYPE" == "podman" ]]; then
|
||||
${SUDO} podman rm -f "${CON_TYPE}-container"
|
||||
elif [[ "$CON_TYPE" == "buildah" ]]; then
|
||||
${SUDO} buildah rm buildah-container
|
||||
fi
|
||||
${SUDO} rm -f /tmp/local_file
|
||||
|
|
@ -40,12 +40,12 @@ DOCUMENTATION = '''
|
|||
# - name: remote_user
|
||||
'''
|
||||
|
||||
import os
|
||||
import shlex
|
||||
import shutil
|
||||
|
||||
import subprocess
|
||||
|
||||
import ansible.constants as C
|
||||
from ansible.errors import AnsibleError
|
||||
from ansible.module_utils._text import to_bytes, to_native
|
||||
from ansible.plugins.connection import ConnectionBase, ensure_connect
|
||||
from ansible.utils.display import Display
|
||||
|
|
@ -73,6 +73,7 @@ class Connection(ConnectionBase):
|
|||
# `buildah inspect` doesn't contain info about what the default user is -- if it's not
|
||||
# set, it's empty
|
||||
self.user = self._play_context.remote_user
|
||||
display.vvvv("Using buildah connection from collection")
|
||||
|
||||
def _set_user(self):
|
||||
self._buildah(b"config", [b"--user=" + to_bytes(self.user, errors='surrogate_or_strict')])
|
||||
|
|
@ -96,6 +97,9 @@ class Connection(ConnectionBase):
|
|||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
|
||||
stdout, stderr = p.communicate(input=in_data)
|
||||
display.vvvvv("STDOUT %s" % stdout)
|
||||
display.vvvvv("STDERR %s" % stderr)
|
||||
display.vvvvv("RC CODE %s" % p.returncode)
|
||||
stdout = to_bytes(stdout, errors='surrogate_or_strict')
|
||||
stderr = to_bytes(stderr, errors='surrogate_or_strict')
|
||||
return p.returncode, stdout, stderr
|
||||
|
|
@ -107,7 +111,11 @@ class Connection(ConnectionBase):
|
|||
"""
|
||||
super(Connection, self)._connect()
|
||||
rc, self._mount_point, stderr = self._buildah("mount")
|
||||
self._mount_point = self._mount_point.strip()
|
||||
if rc != 0:
|
||||
display.v("Failed to mount container %s: %s" % (self._container_id, stderr.strip()))
|
||||
raise AnsibleError(stderr.strip())
|
||||
else:
|
||||
self._mount_point = self._mount_point.strip() + to_bytes(os.path.sep, errors='surrogate_or_strict')
|
||||
display.vvvvv("MOUNTPOINT %s RC %s STDERR %r" % (self._mount_point, rc, stderr))
|
||||
self._connected = True
|
||||
|
||||
|
|
|
|||
|
|
@ -88,6 +88,7 @@ class Connection(ConnectionBase):
|
|||
# container filesystem will be mounted here on host
|
||||
self._mount_point = None
|
||||
self.user = self._play_context.remote_user
|
||||
display.vvvv("Using podman connection from collection")
|
||||
|
||||
def _podman(self, cmd, cmd_args=None, in_data=None, use_container_id=True):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -393,7 +393,7 @@ def main():
|
|||
|
||||
name = module.params['name']
|
||||
executable = module.get_bin_path(module.params['executable'], required=True)
|
||||
|
||||
# pylint: disable=unused-variable
|
||||
inspect_results, out, err = get_containers_facts(module, executable, name)
|
||||
|
||||
results = {
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
hidden
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -eux
|
||||
|
||||
[ -f "${INVENTORY}" ]
|
||||
|
||||
# Run connection tests with both the default and C locale.
|
||||
|
||||
ansible-playbook test_connection.yml -i "${INVENTORY}" "$@"
|
||||
LC_ALL=C LANG=C ansible-playbook test_connection.yml -i "${INVENTORY}" "$@"
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
needs/root
|
||||
non_local
|
||||
unsupported
|
||||
|
|
@ -1 +0,0 @@
|
|||
../connection_posix/test.sh
|
||||
|
|
@ -1,7 +1,19 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -o pipefail
|
||||
set -eux
|
||||
|
||||
./posix.sh "$@"
|
||||
function run_ansible {
|
||||
${SUDO:-} ${ANSIBLECMD:-ansible-playbook} ../connection/test_connection.yml -i "test_connection.inventory" \
|
||||
-e target_hosts="buildah" \
|
||||
-e action_prefix= \
|
||||
-e local_tmp=/tmp/ansible-local \
|
||||
-e remote_tmp=/tmp/ansible-remote \
|
||||
"$@"
|
||||
|
||||
ANSIBLE_REMOTE_USER="1000" ./posix.sh "$@"
|
||||
}
|
||||
|
||||
run_ansible "$@"
|
||||
|
||||
ANSIBLE_VERBOSITY=4 ANSIBLE_REMOTE_USER="1000" run_ansible "$@" | tee check_log
|
||||
${SUDO:-} grep -q "Using buildah connection from collection" check_log
|
||||
${SUDO:-} rm -f check_log
|
||||
|
|
|
|||
|
|
@ -9,4 +9,4 @@ buildah-container ansible_ssh_pipelining=true
|
|||
# 6. remove container
|
||||
# $ sudo buildah rm buildah-container
|
||||
ansible_host=buildah-container
|
||||
ansible_connection=buildah
|
||||
ansible_connection=containers.podman.buildah
|
||||
|
|
|
|||
|
|
@ -1,2 +0,0 @@
|
|||
non_local
|
||||
unsupported
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -eux
|
||||
|
||||
# Connection tests for POSIX platforms use this script by linking to it from the appropriate 'connection_' target dir.
|
||||
# The name of the inventory group to test is extracted from the directory name following the 'connection_' prefix.
|
||||
|
||||
group=$(python -c \
|
||||
"from os import path; print(path.basename(path.abspath(path.dirname('$0'))).replace('connection_', ''))")
|
||||
|
||||
cd ../connection
|
||||
|
||||
INVENTORY="../connection_${group}/test_connection.inventory" ./test.sh \
|
||||
-e target_hosts="${group}" \
|
||||
-e action_prefix= \
|
||||
-e local_tmp=/tmp/ansible-local \
|
||||
-e remote_tmp=/tmp/ansible-remote \
|
||||
"$@"
|
||||
|
|
@ -1,14 +1,28 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -o pipefail
|
||||
set -eux
|
||||
|
||||
./posix.sh "$@"
|
||||
function run_ansible {
|
||||
${SUDO:-} ${ANSIBLECMD:-ansible-playbook} ../connection/test_connection.yml -i "test_connection.inventory" \
|
||||
-e target_hosts="podman" \
|
||||
-e action_prefix= \
|
||||
-e local_tmp=/tmp/ansible-local \
|
||||
-e remote_tmp=/tmp/ansible-remote \
|
||||
"$@"
|
||||
|
||||
ANSIBLE_REMOTE_TMP="/tmp" ANSIBLE_REMOTE_USER="1000" ./posix.sh "$@"
|
||||
ANSIBLE_PODMAN_EXECUTABLE=fakepodman ./posix.sh "$@" 2>&1 | grep "fakepodman command not found in PATH"
|
||||
}
|
||||
|
||||
ANSIBLE_PODMAN_EXECUTABLE=fakepodman ./posix.sh "$@" && {
|
||||
run_ansible "$@"
|
||||
LC_ALL=C LANG=C run_ansible "$@"
|
||||
ANSIBLE_VERBOSITY=4 ANSIBLE_REMOTE_TMP="/tmp" ANSIBLE_REMOTE_USER="1000" run_ansible "$@" | tee check_log
|
||||
${SUDO:-} grep -q "Using podman connection from collection" check_log
|
||||
${SUDO:-} rm -f check_log
|
||||
set +o pipefail
|
||||
ANSIBLE_PODMAN_EXECUTABLE=fakepodman run_ansible "$@" 2>&1 | grep "fakepodman command not found in PATH"
|
||||
set -o pipefail
|
||||
ANSIBLE_PODMAN_EXECUTABLE=fakepodman run_ansible "$@" && {
|
||||
echo "Playbook with fakepodman should fail!"
|
||||
exit 1
|
||||
}
|
||||
ANSIBLE_VERBOSITY=4 ANSIBLE_PODMAN_EXTRA_ARGS=" --log-level debug " ./posix.sh "$@" | grep "level=debug msg="
|
||||
ANSIBLE_VERBOSITY=4 ANSIBLE_PODMAN_EXTRA_ARGS=" --log-level debug " run_ansible "$@" | grep "level=debug msg="
|
||||
|
|
|
|||
|
|
@ -11,5 +11,5 @@ podman-container
|
|||
# podman stop podman-container
|
||||
# podman rm podman-container
|
||||
ansible_host=podman-container
|
||||
ansible_connection=podman
|
||||
ansible_connection=containers.podman.podman
|
||||
ansible_python_interpreter=/usr/local/bin/python
|
||||
|
|
|
|||
|
|
@ -1,2 +0,0 @@
|
|||
needs/target/connection
|
||||
hidden
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -eux
|
||||
|
||||
# Connection tests for POSIX platforms use this script by linking to it from the appropriate 'connection_' target dir.
|
||||
# The name of the inventory group to test is extracted from the directory name following the 'connection_' prefix.
|
||||
|
||||
group=$(python -c \
|
||||
"from os import path; print(path.basename(path.abspath(path.dirname('$0'))).replace('connection_', ''))")
|
||||
|
||||
cd ../connection
|
||||
|
||||
INVENTORY="../connection_${group}/test_connection.inventory" ./test.sh \
|
||||
-e target_hosts="${group}" \
|
||||
-e action_prefix= \
|
||||
-e local_tmp=/tmp/ansible-local \
|
||||
-e remote_tmp=/tmp/ansible-remote \
|
||||
"$@"
|
||||
|
|
@ -1 +0,0 @@
|
|||
podman_package: podman-1.4.*
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
- name: remove podman packages
|
||||
yum:
|
||||
name: 'podman*'
|
||||
state: absent
|
||||
listen: cleanup podman
|
||||
|
||||
- name: remove extras repo
|
||||
command: "{{ repo_command[ansible_facts.distribution ~ ansible_facts.distribution_major_version]['disable'] | default('echo') }}"
|
||||
listen: cleanup podman
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
- block:
|
||||
- name: Enable extras repo
|
||||
command: "{{ repo_command[ansible_facts.distribution ~ ansible_facts.distribution_major_version]['enable'] | default('echo') }}"
|
||||
notify: cleanup podman
|
||||
|
||||
- name: Install podman
|
||||
yum:
|
||||
name: "{{ podman_package }}"
|
||||
state: present
|
||||
when: ansible_facts.pkg_mgr in ['yum', 'dnf']
|
||||
notify: cleanup podman
|
||||
|
||||
- name: Get podman version
|
||||
command: podman --version
|
||||
|
||||
when:
|
||||
- ansible_facts.distribution == 'RedHat'
|
||||
- ansible_facts.virtualization_type != 'docker'
|
||||
- ansible_facts.distribution_major_version is version_compare('7', '>=')
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
repo_command:
|
||||
RedHat7:
|
||||
enable: yum-config-manager --enable rhui-REGION-rhel-server-extras
|
||||
disable: yum-config-manager --disable rhui-REGION-rhel-server-extras
|
||||
|
|
@ -10,3 +10,6 @@ plugins/modules/podman_container.py validate-modules:missing-gplv3-license
|
|||
plugins/modules/podman_container.py validate-modules:parameter-list-no-elements
|
||||
plugins/modules/podman_container.py import-3.7!skip
|
||||
plugins/modules/podman_container.py import-2.7!skip
|
||||
ci/run_connection_test.sh shebang!skip
|
||||
tests/integration/targets/connection_buildah/runme.sh shellcheck:SC2086
|
||||
tests/integration/targets/connection_podman/runme.sh shellcheck:SC2086
|
||||
|
|
|
|||
|
|
@ -5,3 +5,6 @@ plugins/modules/podman_image_info.py validate-modules:parameter-type-not-in-doc
|
|||
plugins/modules/podman_container.py validate-modules!skip
|
||||
plugins/modules/podman_container.py import-3.7!skip
|
||||
plugins/modules/podman_container.py import-2.7!skip
|
||||
ci/run_connection_test.sh shebang!skip
|
||||
tests/integration/targets/connection_buildah/runme.sh shellcheck:SC2086
|
||||
tests/integration/targets/connection_podman/runme.sh shellcheck:SC2086
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue