1
0
Fork 0
mirror of https://github.com/containers/ansible-podman-collections.git synced 2026-02-04 07:11:49 +00:00

Add ubuntu 20.04 to CI as it has podman 2.0.1 version (#83)

Fix idempotency issues in podman_container
Add creating workdir, buildah issue: https://github.com/containers/buildah/issues/2475
Fix #68
Fix #69
Should help to #80 as well, but will be handled separately.
This commit is contained in:
Sergey 2020-07-16 21:21:17 +03:00 committed by GitHub
parent 8bfe7402f0
commit 3726e2a1c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 162 additions and 61 deletions

View file

@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
runner-os:
- ubuntu-16.04
- ubuntu-latest
ansible-version:
- git+https://github.com/ansible/ansible.git@stable-2.10
runner-python-version:
@ -65,6 +65,16 @@ jobs:
python-version:
- 2.7
- 3.7
exclude:
- runner-os: ubuntu-latest
runner-python-version: 3.7
ansible-version: git+https://github.com/ansible/ansible.git@devel
python-version: 3.7
include:
- runner-os: ubuntu-20.04
runner-python-version: 3.7
ansible-version: git+https://github.com/ansible/ansible.git@devel
python-version: 3.7
steps:
- name: Set up Python ${{ matrix.runner-python-version }}

View file

@ -65,10 +65,10 @@ jobs:
path: .cache/collection-tarballs
test-podman-connection:
name: Podman connection VM ${{ matrix.os.vm || 'ubuntu-latest' }}-${{ matrix.ansible-version }}
name: Podman connection VM ${{ matrix.os || 'ubuntu-latest' }}-${{ matrix.ansible-version }}
needs:
- build-collection-artifact-connection-tests
runs-on: ${{ matrix.os.vm || 'ubuntu-latest' }}
runs-on: ${{ matrix.os || 'ubuntu-latest' }}
defaults:
run:
shell: bash
@ -77,17 +77,22 @@ jobs:
matrix:
ansible-version:
- ansible<2.10
- git+https://github.com/ansible/ansible.git@devel
- git+https://github.com/ansible/ansible.git@stable-2.10
os:
- vm: ubuntu-latest
#- vm: ubuntu-16.04
#- vm: macos-latest
- ubuntu-latest
#- ubuntu-20.04
#- ubuntu-16.04
#- macos-latest
python-version:
#- 3.8
- 3.7
#- 3.6
#- 3.5
#- 2.7
include:
- os: ubuntu-20.04
ansible-version: git+https://github.com/ansible/ansible.git@devel
python-version: 3.7
steps:
- name: Check out repository
@ -153,10 +158,10 @@ jobs:
shell: bash
test-buildah-connection:
name: Buildah connection VM ${{ matrix.os.vm || 'ubuntu-latest' }}-${{ matrix.ansible-version }}
name: Buildah connection VM ${{ matrix.os || 'ubuntu-latest' }}-${{ matrix.ansible-version }}
needs:
- build-collection-artifact-connection-tests
runs-on: ${{ matrix.os.vm || 'ubuntu-latest' }}
runs-on: ${{ matrix.os || 'ubuntu-latest' }}
defaults:
run:
shell: bash
@ -165,17 +170,22 @@ jobs:
matrix:
ansible-version:
- ansible<2.10
- git+https://github.com/ansible/ansible.git@devel
- git+https://github.com/ansible/ansible.git@stable-2.10
os:
- vm: ubuntu-latest
#- vm: ubuntu-16.04
#- vm: macos-latest
- ubuntu-latest
#- ubuntu-20.04
#- ubuntu-16.04
#- macos-latest
python-version:
#- 3.8
- 3.7
#- 3.6
#- 3.5
#- 2.7
include:
- os: ubuntu-20.04
ansible-version: git+https://github.com/ansible/ansible.git@devel
python-version: 3.7
steps:
- name: Check out repository

View file

@ -25,8 +25,8 @@ on:
jobs:
test_podman_container:
name: Podman container ${{ matrix.ansible-version }}-${{ matrix.os.vm || 'ubuntu-latest' }}
runs-on: ${{ matrix.os.vm || 'ubuntu-latest' }}
name: Podman container ${{ matrix.ansible-version }}-${{ matrix.os || 'ubuntu-latest' }}
runs-on: ${{ matrix.os || 'ubuntu-latest' }}
defaults:
run:
shell: bash
@ -35,11 +35,15 @@ jobs:
matrix:
ansible-version:
- ansible<2.10
- git+https://github.com/ansible/ansible.git@devel
#- git+https://github.com/ansible/ansible.git@stable-2.10
os:
- vm: ubuntu-latest
- ubuntu-latest
python-version:
- 3.7
include:
- os: ubuntu-20.04
ansible-version: git+https://github.com/ansible/ansible.git@devel
python-version: 3.7
steps:
- name: Check out repository
@ -66,14 +70,18 @@ jobs:
${{ runner.os }}-
- name: Install Ansible ${{ matrix.ansible-version }}
run: python -m pip install --user '${{ matrix.ansible-version }}'
run: python3 -m pip install --user --force-reinstall --upgrade '${{ matrix.ansible-version }}'
- name: Build and install the collection tarball
run: |
export PATH=~/.local/bin:$PATH
echo "Run ansible version"
command -v ansible
ansible --version
rm -rf /tmp/just_new_collection
~/.local/bin/ansible-galaxy collection build --output-path /tmp/just_new_collection --force
~/.local/bin/ansible-galaxy collection install -vvv --force /tmp/just_new_collection/*.tar.gz
sudo ~/.local/bin/ansible-galaxy collection install -vvv --force /tmp/just_new_collection/*.tar.gz
- name: Run collection tests for podman container
run: |

View file

@ -25,8 +25,8 @@ on:
jobs:
test_podman_container_idem:
name: Podman container ${{ matrix.ansible-version }}-${{ matrix.os.vm || 'ubuntu-latest' }}
runs-on: ${{ matrix.os.vm || 'ubuntu-latest' }}
name: Podman container ${{ matrix.ansible-version }}-${{ matrix.os || 'ubuntu-latest' }}
runs-on: ${{ matrix.os || 'ubuntu-latest' }}
defaults:
run:
shell: bash
@ -35,11 +35,15 @@ jobs:
matrix:
ansible-version:
- ansible<2.10
# - git+https://github.com/ansible/ansible.git@devel
# - git+https://github.com/ansible/ansible.git@stable-2.10
os:
- vm: ubuntu-latest
- ubuntu-latest
python-version:
- 3.7
include:
- os: ubuntu-20.04
"ansible-version": git+https://github.com/ansible/ansible.git@devel
"python-version": 3.7
steps:
- name: Check out repository
@ -66,19 +70,22 @@ jobs:
${{ runner.os }}-
- name: Install Ansible ${{ matrix.ansible-version }}
run: python -m pip install --user '${{ matrix.ansible-version }}'
run: python3 -m pip install --user --force-reinstall --upgrade '${{ matrix.ansible-version }}'
- name: Build and install the collection tarball
run: |
rm -rf /tmp/just_new_collection
~/.local/bin/ansible-galaxy collection build --output-path /tmp/just_new_collection --force
~/.local/bin/ansible-galaxy collection install -vvv --force /tmp/just_new_collection/*.tar.gz
sudo ~/.local/bin/ansible-galaxy collection install -vvv --force /tmp/just_new_collection/*.tar.gz
- name: Run idempotency tests for podman container
run: |
export PATH=~/.local/bin:$PATH
echo "Run ansible version"
command -v ansible
ansible --version
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

View file

@ -25,8 +25,8 @@ on:
jobs:
test_podman_container_info:
name: Podman container info ${{ matrix.ansible-version }}-${{ matrix.os.vm || 'ubuntu-latest' }}
runs-on: ${{ matrix.os.vm || 'ubuntu-latest' }}
name: Podman container info ${{ matrix.ansible-version }}-${{ matrix.os || 'ubuntu-latest' }}
runs-on: ${{ matrix.os || 'ubuntu-latest' }}
defaults:
run:
shell: bash
@ -35,11 +35,15 @@ jobs:
matrix:
ansible-version:
- ansible<2.10
- git+https://github.com/ansible/ansible.git@devel
# - git+https://github.com/ansible/ansible.git@stable-2.10
os:
- vm: ubuntu-latest
- ubuntu-latest
python-version:
- 3.7
include:
- os: ubuntu-20.04
ansible-version: git+https://github.com/ansible/ansible.git@devel
python-version: 3.7
steps:
- name: Check out repository
@ -66,19 +70,22 @@ jobs:
${{ runner.os }}-
- name: Install Ansible ${{ matrix.ansible-version }}
run: python -m pip install --user '${{ matrix.ansible-version }}'
run: python3 -m pip install --user --force-reinstall --upgrade '${{ matrix.ansible-version }}'
- name: Build and install the collection tarball
run: |
rm -rf /tmp/just_new_collection
~/.local/bin/ansible-galaxy collection build --output-path /tmp/just_new_collection --force
~/.local/bin/ansible-galaxy collection install -vvv --force /tmp/just_new_collection/*.tar.gz
sudo ~/.local/bin/ansible-galaxy collection install -vvv --force /tmp/just_new_collection/*.tar.gz
- name: Run collection tests for podman container info
run: |
export PATH=~/.local/bin:$PATH
echo "Run ansible version"
command -v ansible
ansible --version
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

View file

@ -25,8 +25,8 @@ on:
jobs:
test_podman_image:
name: Podman image ${{ matrix.ansible-version }}-${{ matrix.os.vm || 'ubuntu-latest' }}
runs-on: ${{ matrix.os.vm || 'ubuntu-latest' }}
name: Podman image ${{ matrix.ansible-version }}-${{ matrix.os || 'ubuntu-latest' }}
runs-on: ${{ matrix.os || 'ubuntu-latest' }}
defaults:
run:
shell: bash
@ -35,11 +35,15 @@ jobs:
matrix:
ansible-version:
- ansible<2.10
- git+https://github.com/ansible/ansible.git@devel
# - git+https://github.com/ansible/ansible.git@stable-2.10
os:
- vm: ubuntu-latest
- ubuntu-latest
python-version:
- 3.7
include:
- os: ubuntu-20.04
ansible-version: git+https://github.com/ansible/ansible.git@devel
python-version: 3.7
steps:
- name: Check out repository
@ -66,19 +70,22 @@ jobs:
${{ runner.os }}-
- name: Install Ansible ${{ matrix.ansible-version }}
run: python -m pip install --user '${{ matrix.ansible-version }}'
run: python3 -m pip install --user --force-reinstall --upgrade '${{ matrix.ansible-version }}'
- name: Build and install the collection tarball
run: |
rm -rf /tmp/just_new_collection
~/.local/bin/ansible-galaxy collection build --output-path /tmp/just_new_collection --force
~/.local/bin/ansible-galaxy collection install -vvv --force /tmp/just_new_collection/*.tar.gz
sudo ~/.local/bin/ansible-galaxy collection install -vvv --force /tmp/just_new_collection/*.tar.gz
- name: Run collection tests for podman image
run: |
export PATH=~/.local/bin:$PATH
echo "Run ansible version"
command -v ansible
ansible --version
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

View file

@ -25,8 +25,8 @@ on:
jobs:
test_podman_image_info:
name: Podman image info ${{ matrix.ansible-version }}-${{ matrix.os.vm || 'ubuntu-latest' }}
runs-on: ${{ matrix.os.vm || 'ubuntu-latest' }}
name: Podman image info ${{ matrix.ansible-version }}-${{ matrix.os || 'ubuntu-latest' }}
runs-on: ${{ matrix.os || 'ubuntu-latest' }}
defaults:
run:
shell: bash
@ -35,11 +35,15 @@ jobs:
matrix:
ansible-version:
- ansible<2.10
- git+https://github.com/ansible/ansible.git@devel
# - git+https://github.com/ansible/ansible.git@stable-2.10
os:
- vm: ubuntu-latest
- ubuntu-latest
python-version:
- 3.7
include:
- os: ubuntu-20.04
ansible-version: git+https://github.com/ansible/ansible.git@devel
python-version: 3.7
steps:
- name: Check out repository
@ -66,19 +70,22 @@ jobs:
${{ runner.os }}-
- name: Install Ansible ${{ matrix.ansible-version }}
run: python -m pip install --user '${{ matrix.ansible-version }}'
run: python3 -m pip install --user --force-reinstall --upgrade '${{ matrix.ansible-version }}'
- name: Build and install the collection tarball
run: |
rm -rf /tmp/just_new_collection
~/.local/bin/ansible-galaxy collection build --output-path /tmp/just_new_collection --force
~/.local/bin/ansible-galaxy collection install -vvv --force /tmp/just_new_collection/*.tar.gz
sudo ~/.local/bin/ansible-galaxy collection install -vvv --force /tmp/just_new_collection/*.tar.gz
- name: Run collection tests for podman image info
run: |
export PATH=~/.local/bin:$PATH
echo "Run ansible version"
command -v ansible
ansible --version
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

View file

@ -23,8 +23,8 @@ on:
jobs:
test_podman_network_info:
name: Podman network info ${{ matrix.ansible-version }}-${{ matrix.os.vm || 'ubuntu-latest' }}
runs-on: ${{ matrix.os.vm || 'ubuntu-latest' }}
name: Podman network info ${{ matrix.ansible-version }}-${{ matrix.os || 'ubuntu-latest' }}
runs-on: ${{ matrix.os || 'ubuntu-latest' }}
defaults:
run:
shell: bash
@ -33,11 +33,15 @@ jobs:
matrix:
ansible-version:
- ansible<2.10
- git+https://github.com/ansible/ansible.git@devel
# - git+https://github.com/ansible/ansible.git@stable-2.10
os:
- vm: ubuntu-latest
- ubuntu-latest
python-version:
- 3.7
include:
- os: ubuntu-20.04
ansible-version: git+https://github.com/ansible/ansible.git@devel
python-version: 3.7
steps:
- name: Check out repository
@ -64,19 +68,22 @@ jobs:
${{ runner.os }}-
- name: Install Ansible ${{ matrix.ansible-version }}
run: python -m pip install --user '${{ matrix.ansible-version }}'
run: python3 -m pip install --user --force-reinstall --upgrade '${{ matrix.ansible-version }}'
- name: Build and install the collection tarball
run: |
rm -rf /tmp/just_new_collection
~/.local/bin/ansible-galaxy collection build --output-path /tmp/just_new_collection --force
~/.local/bin/ansible-galaxy collection install -vvv --force /tmp/just_new_collection/*.tar.gz
sudo ~/.local/bin/ansible-galaxy collection install -vvv --force /tmp/just_new_collection/*.tar.gz
- name: Run collection tests for podman network info
run: |
export PATH=~/.local/bin:$PATH
echo "Run ansible version"
command -v ansible
ansible --version
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

View file

@ -23,8 +23,8 @@ on:
jobs:
test_podman_volume_info:
name: Podman volume info ${{ matrix.ansible-version }}-${{ matrix.os.vm || 'ubuntu-latest' }}
runs-on: ${{ matrix.os.vm || 'ubuntu-latest' }}
name: Podman volume info ${{ matrix.ansible-version }}-${{ matrix.os || 'ubuntu-latest' }}
runs-on: ${{ matrix.os || 'ubuntu-latest' }}
defaults:
run:
shell: bash
@ -33,11 +33,15 @@ jobs:
matrix:
ansible-version:
- ansible<2.10
- git+https://github.com/ansible/ansible.git@devel
# - git+https://github.com/ansible/ansible.git@stable-2.10
os:
- vm: ubuntu-latest
- ubuntu-latest
python-version:
- 3.7
include:
- os: ubuntu-20.04
ansible-version: git+https://github.com/ansible/ansible.git@devel
python-version: 3.7
steps:
- name: Check out repository
@ -64,19 +68,22 @@ jobs:
${{ runner.os }}-
- name: Install Ansible ${{ matrix.ansible-version }}
run: python -m pip install --user '${{ matrix.ansible-version }}'
run: python3 -m pip install --user --force-reinstall --upgrade '${{ matrix.ansible-version }}'
- name: Build and install the collection tarball
run: |
rm -rf /tmp/just_new_collection
~/.local/bin/ansible-galaxy collection build --output-path /tmp/just_new_collection --force
~/.local/bin/ansible-galaxy collection install -vvv --force /tmp/just_new_collection/*.tar.gz
sudo ~/.local/bin/ansible-galaxy collection install -vvv --force /tmp/just_new_collection/*.tar.gz
- name: Run collection tests for podman volume info
run: |
export PATH=~/.local/bin:$PATH
echo "Run ansible version"
command -v ansible
ansible --version
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

View file

@ -39,4 +39,4 @@ if [[ "$CON_TYPE" == "podman" ]]; then
elif [[ "$CON_TYPE" == "buildah" ]]; then
${SUDO} buildah rm buildah-container
fi
${SUDO} rm -f /tmp/local_file
sudo rm -f /tmp/local_file /tmp/remote_file

View file

@ -15,7 +15,8 @@ exit_code=0
CMD="ANSIBLE_ROLES_PATH=${CURWD}/../tests/integration/targets \
${ANSIBLECMD:-ansible-playbook} \
-i localhost, -c local --diff \
ci/playbooks/containers/${TEST2RUN}.yml"
ci/playbooks/containers/${TEST2RUN}.yml \
-e ansible_python_interpreter=$(command -v python)"
bash -c "$CMD -vv" || exit_code=$?
if [[ "$exit_code" != 0 ]]; then

View file

@ -1598,9 +1598,13 @@ class PodmanContainerDiff:
def diffparam_network(self):
before = [self.info['hostconfig']['networkmode']]
after = self.params['network']
if self.params['pod'] and not self.module.params['network']:
# TODO(sshnaidm): special case for rootful container > v2.
# Discover later what is running user and set default accordingly
if not self.module.params['network'] and (
before == ['bridge'] or self.params['pod']):
after = before
else:
after = self.params['network']
return self._diff_update_and_compare('network', before, after)
def diffparam_no_hosts(self):
@ -1653,6 +1657,8 @@ class PodmanContainerDiff:
def diffparam_security_opt(self):
before = self.info['hostconfig']['securityopt']
# In rootful containers with apparmor there is a default security opt
before = [o for o in before if 'apparmor=containers-default' not in o]
after = self.params['security_opt']
before, after = sorted(list(set(before))), sorted(list(set(after)))
return self._diff_update_and_compare('security_opt', before, after)

View file

@ -119,6 +119,10 @@ DOCUMENTATION = r'''
description: Remove intermediate containers after a successful build
type: bool
default: True
extra_args:
description:
- Extra args to pass to build, if executed. Does not idempotently check for new build args.
type: str
push_args:
description: Arguments that control pushing images.
type: dict
@ -376,6 +380,7 @@ RETURN = r"""
import json
import re
import shlex
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.containers.podman.plugins.module_utils.podman.common import run_podman_command
@ -574,6 +579,10 @@ class PodmanImageManager(object):
cred_string = '{user}:{password}'.format(user=self.username, password=self.password)
args.extend(['--creds', cred_string])
extra_args = self.build.get('extra_args')
if extra_args:
args.extend([arg for arg in shlex.split(extra_args)])
args.append(self.path)
rc, out, err = self._run(args, ignore_errors=True)
@ -714,6 +723,7 @@ def main():
cache=dict(type='bool', default=True),
rm=dict(type='bool', default=True),
volume=dict(type='list', elements='str'),
extra_args=dict(type='str'),
),
),
push_args=dict(

View file

@ -8,6 +8,8 @@ ARG build_arg
ENV password root
ENV username root
WORKDIR /work
RUN adduser -D user && \
adduser -D user2
@ -17,10 +19,8 @@ RUN chmod a+rwx /start
EXPOSE 80
EXPOSE 8080/tcp
VOLUME ["/data", "/data2"]
USER user
WORKDIR /work
STOPSIGNAL 9
# problem with OS w/o systemd

View file

@ -19,6 +19,7 @@
path: /tmp/usr_img
build:
format: docker
extra_args: --cgroup-manager=cgroupfs
- name: Build test docker image for root user
containers.podman.podman_image:

View file

@ -12,6 +12,19 @@
state: present
command: 1h
- name: Run container as is again
containers.podman.podman_container:
image: "{{ idem_image }}"
name: root-idempotency
state: present
command: 1h
register: info_a
- name: Check that it is not recreated
assert:
that:
- info_a is not changed
- name: Run containers with ulimits
containers.podman.podman_container:
image: "{{ idem_image }}"