Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
704b236
add incomplete module
johnsonlien Apr 5, 2025
3142ba4
add RETURN value and a test
johnsonlien Apr 5, 2025
7f2c399
add another example
johnsonlien Apr 5, 2025
3ee0c54
add log if system info fails
johnsonlien Apr 5, 2025
e9b1c5d
Update podman_system_info.py
johnsonlien Apr 8, 2025
162ee42
add workflow for podman_system_info module
johnsonlien Apr 15, 2025
ddb0d51
add ansible python interpreter to var for podman_system_info
johnsonlien Apr 16, 2025
1c857fe
have RETURN be yaml format
johnsonlien Apr 16, 2025
b576ca5
add integration test to workflow
johnsonlien Apr 16, 2025
eec08a8
remove extra closing brace
johnsonlien Apr 29, 2025
d69625e
remove '--format json' from description
johnsonlien Apr 29, 2025
9d10714
add missing double quotes
johnsonlien Apr 29, 2025
c1da79a
add requirements and options section to DOCUMENTATION
johnsonlien Apr 29, 2025
79438c1
split long sentence to newline
johnsonlien Apr 29, 2025
dcd654f
Merge branch 'containers:main' into add-podman_system_info-module
johnsonlien Apr 29, 2025
342857f
add integration test to workflow
johnsonlien Apr 16, 2025
a3f28d5
remove extra closing brace
johnsonlien Apr 29, 2025
eda19cf
remove '--format json' from description
johnsonlien Apr 29, 2025
e377ac5
add missing double quotes
johnsonlien Apr 29, 2025
5104c0d
add requirements and options section to DOCUMENTATION
johnsonlien Apr 29, 2025
8045bf5
split long sentence to newline
johnsonlien Apr 29, 2025
66c0ead
Merge branch 'add-podman_system_info-module' of github.com:johnsonlie…
johnsonlien Apr 29, 2025
ec2f66d
add missing curly brace in ci/playbooks/containers/podman_system_info
johnsonlien Apr 29, 2025
983ffc8
Release 1.16.3 (#897)
sshnaidm Jan 29, 2025
d00b2de
fix(podman_image): correct intendation on 'loop' keyword (#903)
transcaffeine Feb 17, 2025
7b5ec05
Remove docker protocol when inspecting image (#901)
sshnaidm Feb 17, 2025
42fad01
Use usedforsecurity for hashlib.sha256 only in python version >=3.9 (…
sents Feb 17, 2025
4a91c22
doc: podman_secret: fix indentation error in example (#905)
jeu-umanit Mar 3, 2025
18d7760
Fix CI for podman_image_info (#912)
sshnaidm Mar 9, 2025
058cd57
Document that sdnotify can be set to healthy (#911)
ekohl Mar 10, 2025
285f1fc
add incomplete module
johnsonlien Apr 5, 2025
6c1f17e
add RETURN value and a test
johnsonlien Apr 5, 2025
7f2b410
add another example
johnsonlien Apr 5, 2025
a55474c
add log if system info fails
johnsonlien Apr 5, 2025
fac2e1d
Update podman_system_info.py
johnsonlien Apr 8, 2025
d98cc56
add workflow for podman_system_info module
johnsonlien Apr 15, 2025
fa4bb59
add ansible python interpreter to var for podman_system_info
johnsonlien Apr 16, 2025
498c6a7
have RETURN be yaml format
johnsonlien Apr 16, 2025
5e6bf4d
add integration test to workflow
johnsonlien Apr 16, 2025
a5f4608
remove extra closing brace
johnsonlien Apr 29, 2025
6a7eefb
remove '--format json' from description
johnsonlien Apr 29, 2025
429be95
add missing double quotes
johnsonlien Apr 29, 2025
ce5e456
add requirements and options section to DOCUMENTATION
johnsonlien Apr 29, 2025
7e21a7e
split long sentence to newline
johnsonlien Apr 29, 2025
d4aa649
correctly quote labels and environment variables for quadlets (#920)
evgeni Apr 14, 2025
388a628
Fix setuptools (#925)
sshnaidm Apr 21, 2025
230f14a
Fix conditions in CI jobs (#928)
sshnaidm Apr 27, 2025
179f219
add missing curly brace in ci/playbooks/containers/podman_system_info
johnsonlien Apr 29, 2025
9aa5d9c
Add systeminfo module
johnsonlien Apr 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 107 additions & 0 deletions .github/workflows/podman_system_info.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: Podman system info

on:
push:
paths:
- '.github/workflows/podman_system_info.yml'
- 'ci/*.yml'
- 'ci/run_containers_tests.sh'
- 'ci/playbooks/containers/podman_system_info.yml'
- 'plugins/modules/podman_system_info.py'
- 'tests/integration/targets/podman_system_info/**'
branches:
- main
pull_request:
paths:
- '.github/workflows/podman_system_info.yml'
- 'ci/*.yml'
- 'ci/run_containers_tests.sh'
- 'ci/playbooks/containers/podman_system_info.yml'
- 'plugins/modules/podman_system_info.py'
- 'tests/integration/targets/podman_system_info/**'
schedule:
- cron: 4 0 * * * # Run daily at 0:03 UTC

jobs:

test_podman_system_info:
name: Podman system info ${{ matrix.ansible-version }}-${{ matrix.os || 'ubuntu-22.04' }}
runs-on: ${{ matrix.os || 'ubuntu-22.04' }}
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
ansible-version:
- git+https://github.com/ansible/[email protected]
- git+https://github.com/ansible/ansible.git@devel
os:
- ubuntu-22.04
python-version:
- "3.11"

steps:

- name: Check out repository
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Upgrade pip and display Python and PIP versions
run: |
sudo apt-get update
sudo apt-get install -y python*-wheel python*-yaml
python -m pip install --upgrade pip
python -V
pip --version

- name: Set up pip cache
uses: actions/cache@v4
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: 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

- name: Run collection tests for podman system info
run: |
export PATH=~/.local/bin:$PATH

export ANSIBLE_CONFIG=$(pwd)/ci/ansible-dev.cfg
if [[ '${{ 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

TEST2RUN=podman_system_info ./ci/run_containers_tests.sh
shell: bash
8 changes: 8 additions & 0 deletions ci/playbooks/containers/podman_system_info.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
- hosts: all
gather_facts: true
tasks:
- include_role:
name: podman_system_info
vars:
ansible_python_interpreter: "{{ _ansible_python_interpreter }"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ansible_python_interpreter: "{{ _ansible_python_interpreter }"
ansible_python_interpreter: "{{ _ansible_python_interpreter }}"

209 changes: 209 additions & 0 deletions plugins/modules/podman_system_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
#!/usr/bin/python
# Copyright (c) 2025 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

from __future__ import absolute_import, division, print_function
__metaclass__ = type

DOCUMENTATION = r'''
module: podman_system_info
author:
- Johnson Lien (@johnsonlien)
short_description: Get podman system information from host machine
description: Runs "podman system info --format json" on host machine
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should document arguments here, like executable

'''

EXAMPLES = r'''
- name: Get Podman system information
containers.podman.podman_system_info:

- name: Get Podman system information into a variable
containers.podman.podman_system_info:
register: podman_info
- name: Printing Podman System info
debug:
msg: "{{ podman_info['podman_system_info'] }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no ending double quote

Suggested change
msg: "{{ podman_info['podman_system_info'] }}
msg: "{{ podman_info['podman_system_info'] }}"

'''

RETURN = r'''
host:
arch: amd64
buildahVersion: 1.23.0
cgroupControllers: []
cgroupManager: systemd
cgroupVersion: v2
conmon:
package: conmon-2.0.29-2.fc34.x86_64
path: /usr/bin/conmon
version: 'conmon version 2.0.29, commit: '
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
version: 'conmon version 2.0.29, commit: '
version: 'conmon version 2.0.29, commit '

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this breaks yaml

cpu_utilization:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cpu_utilization:
cpu_utilization:

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this breaks yaml, wrong indent

idle_percent: 96.84
system_percent: 0.71
user_percent: 2.45
cpus: 8
distribution:
distribution: fedora
variant: workstation
version: "34"
eventLogger: journald
hostname: localhost.localdomain
idMappings:
gidmap:
- container_id: 0
host_id: 3267
size: 1
- container_id: 1
host_id: 100000
size: 65536
uidmap:
- container_id: 0
host_id: 3267
size: 1
- container_id: 1
host_id: 100000
size: 65536
kernel: 5.13.13-200.fc34.x86_64
linkmode: dynamic
logDriver: journald
memFree: 1833385984
memTotal: 16401895424
networkBackend: cni
networkBackendInfo:
backend: cni
dns:
package: podman-plugins-3.4.4-1.fc34.x86_64
path: /usr/libexec/cni/dnsname
version: |-
CNI dnsname plugin
version: 1.3.1
commit: unknown
package: |-
containernetworking-plugins-1.0.1-1.fc34.x86_64
podman-plugins-3.4.4-1.fc34.x86_64
path: /usr/libexec/cni
ociRuntime:
name: crun
package: crun-1.0-1.fc34.x86_64
path: /usr/bin/crun
version: |-
crun version 1.0
commit: 139dc6971e2f1d931af520188763e984d6cdfbf8
spec: 1.0.0
+SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +YAJL
os: linux
pasta:
executable: /usr/bin/passt
package: passt-0^20221116.gace074c-1.fc34.x86_64
version: |
passt 0^20221116.gace074c-1.fc34.x86_64
Copyright Red Hat
GNU Affero GPL version 3 or later <https://www.gnu.org/licenses/agpl-3.0.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
remoteSocket:
path: /run/user/3267/podman/podman.sock
security:
apparmorEnabled: false
capabilities: CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_NET_BIND_SERVICE,CAP_SETFCAP,CAP_SETGID,CAP_SETPCAP,CAP_SETUID
rootless: true
seccompEnabled: true
seccompProfilePath: /usr/share/containers/seccomp.json
selinuxEnabled: true
serviceIsRemote: false
slirp4netns:
executable: /bin/slirp4netns
package: slirp4netns-1.1.12-2.fc34.x86_64
version: |-
slirp4netns version 1.1.12
commit: 7a104a101aa3278a2152351a082a6df71f57c9a3
libslirp: 4.4.0
SLIRP_CONFIG_VERSION_MAX: 3
libseccomp: 2.5.0
swapFree: 15687475200
swapTotal: 16886259712
uptime: 47h 15m 9.91s (Approximately 1.96 days)
plugins:
log:
- k8s-file
- none
- journald
network:
- bridge
- macvlan
volume:
- local
registries:
search:
- registry.fedoraproject.org
- registry.access.redhat.com
- docker.io
- quay.io
store:
configFile: /home/dwalsh/.config/containers/storage.conf
containerStore:
number: 9
paused: 0
running: 1
stopped: 8
graphDriverName: overlay
graphOptions: {}
graphRoot: /home/dwalsh/.local/share/containers/storage
graphRootAllocated: 510389125120
graphRootUsed: 129170714624
graphStatus:
Backing Filesystem: extfs
Native Overlay Diff: "true"
Supports d_type: "true"
Using metacopy: "false"
imageCopyTmpDir: /home/dwalsh/.local/share/containers/storage/tmp
imageStore:
number: 5
runRoot: /run/user/3267/containers
transientStore: false
volumePath: /home/dwalsh/.local/share/containers/storage/volumes
version:
APIVersion: 4.0.0
Built: 1631648722
BuiltTime: Tue Sep 14 15:45:22 2021
GitCommit: 23677f92dd83e96d2bc8f0acb611865fb8b1a56d
GoVersion: go1.16.6
OsArch: linux/amd64
Version: 4.0.0
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this

Suggested change
}

'''

import json

from ansible.module_utils.basic import AnsibleModule

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

def get_podman_system_info(module, executable):
command = [executable, 'system', 'info']
rc, out, err = module.run_command(command)
out = out.strip()
if out:
return json.loads(out)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

module.log(msg="Unable to get podman system info: %s" % err)
return json.dumps([])

def main():
module = AnsibleModule(
argument_spec=dict(
executable=dict(type='str', default='podman'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add it in doc above.

),
supports_check_mode=True,
)

executable = module.get_bin_path(module.params['executable'], required=True)

results = get_podman_system_info(module, executable)

results = dict(
changed=False,
podman_system_info=results,
)

module.exit_json(**results)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

if __name__ == '__main__':
main()
8 changes: 8 additions & 0 deletions tests/integration/targets/podman_system_info/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
- name: Get Podman system info
containers.podman.podman_system_info:
register: podman_info

- name: Check results
assert:
that:
- podman_info.podman_system_info | length > 0
Loading