-
-
Notifications
You must be signed in to change notification settings - Fork 164
Add podman system info module #922
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
sshnaidm
merged 49 commits into
containers:main
from
johnsonlien:add-podman_system_info-module
Jun 22, 2025
Merged
Changes from all commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
704b236
add incomplete module
johnsonlien 3142ba4
add RETURN value and a test
johnsonlien 7f2c399
add another example
johnsonlien 3ee0c54
add log if system info fails
johnsonlien e9b1c5d
Update podman_system_info.py
johnsonlien 162ee42
add workflow for podman_system_info module
johnsonlien ddb0d51
add ansible python interpreter to var for podman_system_info
johnsonlien 1c857fe
have RETURN be yaml format
johnsonlien b576ca5
add integration test to workflow
johnsonlien eec08a8
remove extra closing brace
johnsonlien d69625e
remove '--format json' from description
johnsonlien 9d10714
add missing double quotes
johnsonlien c1da79a
add requirements and options section to DOCUMENTATION
johnsonlien 79438c1
split long sentence to newline
johnsonlien dcd654f
Merge branch 'containers:main' into add-podman_system_info-module
johnsonlien 342857f
add integration test to workflow
johnsonlien a3f28d5
remove extra closing brace
johnsonlien eda19cf
remove '--format json' from description
johnsonlien e377ac5
add missing double quotes
johnsonlien 5104c0d
add requirements and options section to DOCUMENTATION
johnsonlien 8045bf5
split long sentence to newline
johnsonlien 66c0ead
Merge branch 'add-podman_system_info-module' of github.com:johnsonlie…
johnsonlien ec2f66d
add missing curly brace in ci/playbooks/containers/podman_system_info
johnsonlien 983ffc8
Release 1.16.3 (#897)
sshnaidm d00b2de
fix(podman_image): correct intendation on 'loop' keyword (#903)
transcaffeine 7b5ec05
Remove docker protocol when inspecting image (#901)
sshnaidm 42fad01
Use usedforsecurity for hashlib.sha256 only in python version >=3.9 (…
sents 4a91c22
doc: podman_secret: fix indentation error in example (#905)
jeu-umanit 18d7760
Fix CI for podman_image_info (#912)
sshnaidm 058cd57
Document that sdnotify can be set to healthy (#911)
ekohl 285f1fc
add incomplete module
johnsonlien 6c1f17e
add RETURN value and a test
johnsonlien 7f2b410
add another example
johnsonlien a55474c
add log if system info fails
johnsonlien fac2e1d
Update podman_system_info.py
johnsonlien d98cc56
add workflow for podman_system_info module
johnsonlien fa4bb59
add ansible python interpreter to var for podman_system_info
johnsonlien 498c6a7
have RETURN be yaml format
johnsonlien 5e6bf4d
add integration test to workflow
johnsonlien a5f4608
remove extra closing brace
johnsonlien 6a7eefb
remove '--format json' from description
johnsonlien 429be95
add missing double quotes
johnsonlien ce5e456
add requirements and options section to DOCUMENTATION
johnsonlien 7e21a7e
split long sentence to newline
johnsonlien d4aa649
correctly quote labels and environment variables for quadlets (#920)
evgeni 388a628
Fix setuptools (#925)
sshnaidm 230f14a
Fix conditions in CI jobs (#928)
sshnaidm 179f219
add missing curly brace in ci/playbooks/containers/podman_system_info
johnsonlien 9aa5d9c
Add systeminfo module
johnsonlien File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 }}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,264 @@ | ||||||||
| #!/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" on host machine | ||||||||
| requirements: | ||||||||
| - "Podman installed on host" | ||||||||
| options: | ||||||||
| executable: | ||||||||
| description: | ||||||||
| - Path to C(podman) executable if it is not in the C($PATH) on the | ||||||||
| machine running C(podman) | ||||||||
| default: 'podman' | ||||||||
| type: str | ||||||||
| """ | ||||||||
|
|
||||||||
| 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'] }}" | ||||||||
| """ | ||||||||
|
|
||||||||
| RETURN = r""" | ||||||||
| podman_system_info: | ||||||||
| description: System information from podman | ||||||||
| returned: always | ||||||||
| type: dict | ||||||||
| sample: | ||||||||
| { | ||||||||
| "host": { | ||||||||
| "arch": "amd64", | ||||||||
| "buildahVersion": "1.40.1", | ||||||||
| "cgroupManager": "systemd", | ||||||||
| "cgroupVersion": "v2", | ||||||||
| "cgroupControllers": [ | ||||||||
| "cpu", | ||||||||
| "io", | ||||||||
| "memory", | ||||||||
| "pids" | ||||||||
| ], | ||||||||
| "conmon": { | ||||||||
| "package": "conmon-2.1.13-1.fc41.x86_64", | ||||||||
| "path": "/usr/bin/conmon", | ||||||||
| "version": "conmon version 2.1.13, commit " | ||||||||
| }, | ||||||||
| "cpus": 12, | ||||||||
| "cpuUtilization": { | ||||||||
| "userPercent": 5.73, | ||||||||
| "systemPercent": 2.15, | ||||||||
| "idlePercent": 92.12 | ||||||||
| }, | ||||||||
| "databaseBackend": "boltdb", | ||||||||
| "distribution": { | ||||||||
| "distribution": "fedora", | ||||||||
| "variant": "workstation", | ||||||||
| "version": "41" | ||||||||
| }, | ||||||||
| "eventLogger": "journald", | ||||||||
| "freeLocks": 897, | ||||||||
| "hostname": "user.remote", | ||||||||
| "idMappings": { | ||||||||
| "gidmap": [ | ||||||||
| { | ||||||||
| "container_id": 0, | ||||||||
| "host_id": 1000, | ||||||||
| "size": 1 | ||||||||
| }, | ||||||||
| { | ||||||||
| "container_id": 1, | ||||||||
| "host_id": 100000, | ||||||||
| "size": 65536 | ||||||||
| } | ||||||||
| ], | ||||||||
| "uidmap": [ | ||||||||
| { | ||||||||
| "container_id": 0, | ||||||||
| "host_id": 1000, | ||||||||
| "size": 1 | ||||||||
| }, | ||||||||
| { | ||||||||
| "container_id": 1, | ||||||||
| "host_id": 100000, | ||||||||
| "size": 65536 | ||||||||
| } | ||||||||
| ] | ||||||||
| }, | ||||||||
| "kernel": "6.14.9-200.fc41.x86_64", | ||||||||
| "logDriver": "journald", | ||||||||
| "memFree": 3055095808, | ||||||||
| "memTotal": 67157032960, | ||||||||
| "networkBackend": "netavark", | ||||||||
| "networkBackendInfo": { | ||||||||
| "backend": "netavark", | ||||||||
| "version": "netavark 1.15.2", | ||||||||
| "package": "netavark-1.15.2-1.fc41.x86_64", | ||||||||
| "path": "/usr/libexec/podman/netavark", | ||||||||
| "dns": { | ||||||||
| "version": "aardvark-dns 1.15.0", | ||||||||
| "package": "aardvark-dns-1.15.0-1.fc41.x86_64", | ||||||||
| "path": "/usr/libexec/podman/aardvark-dns" | ||||||||
| } | ||||||||
| }, | ||||||||
| "ociRuntime": { | ||||||||
| "name": "crun", | ||||||||
| "package": "crun-1.21-1.fc41.x86_64", | ||||||||
| "path": "/usr/bin/crun", | ||||||||
| "version": "crun version 1.21..." | ||||||||
| }, | ||||||||
| "os": "linux", | ||||||||
| "remoteSocket": { | ||||||||
| "path": "/run/user/1000/podman/podman.sock", | ||||||||
| "exists": true | ||||||||
| }, | ||||||||
| "rootlessNetworkCmd": "pasta", | ||||||||
| "serviceIsRemote": false, | ||||||||
| "security": { | ||||||||
| "apparmorEnabled": false, | ||||||||
| "capabilities": "CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,...", | ||||||||
| "rootless": true, | ||||||||
| "seccompEnabled": true, | ||||||||
| "seccompProfilePath": "/usr/share/containers/seccomp.json", | ||||||||
| "selinuxEnabled": true | ||||||||
| }, | ||||||||
| "slirp4netns": { | ||||||||
| "executable": "/usr/bin/slirp4netns", | ||||||||
| "package": "slirp4netns-1.3.1-1.fc41.x86_64", | ||||||||
| "version": "slirp4netns version 1.3.1\ncommit..." | ||||||||
| }, | ||||||||
| "pasta": { | ||||||||
| "executable": "/usr/bin/pasta", | ||||||||
| "package": "passt-0^20250611.g0293c6f-1.fc41.x86_64", | ||||||||
| "version": "pasta 0^20250611.g0293c6f-1.fc41.x86_64\nCopyright Red Hat\n..." | ||||||||
| }, | ||||||||
| "swapFree": 1911504896, | ||||||||
| "swapTotal": 8589930496, | ||||||||
| "uptime": "115h 11m 51.00s (Approximately 3.88 days)", | ||||||||
| "variant": "", | ||||||||
| "linkmode": "dynamic" | ||||||||
| }, | ||||||||
| "store": { | ||||||||
| "configFile": "/home/user/.config/containers/storage.conf", | ||||||||
| "containerStore": { | ||||||||
| "number": 6, | ||||||||
| "paused": 0, | ||||||||
| "running": 1, | ||||||||
| "stopped": 5 | ||||||||
| }, | ||||||||
| "graphDriverName": "overlay", | ||||||||
| "graphOptions": { | ||||||||
| "overlay.mountopt": "nodev" | ||||||||
| }, | ||||||||
| "graphRoot": "/home/user/.local/share/containers/storage", | ||||||||
| "graphRootAllocated": 502921060352, | ||||||||
| "graphRootUsed": 457285541888, | ||||||||
| "graphStatus": { | ||||||||
| "Backing Filesystem": "extfs", | ||||||||
| "Native Overlay Diff": "false", | ||||||||
| "Supports d_type": "true", | ||||||||
| "Supports shifting": "true", | ||||||||
| "Supports volatile": "true", | ||||||||
| "Using metacopy": "false" | ||||||||
| }, | ||||||||
| "imageCopyTmpDir": "/var/tmp", | ||||||||
| "imageStore": { | ||||||||
| "number": 859 | ||||||||
| }, | ||||||||
| "runRoot": "/run/user/1000/containers", | ||||||||
| "volumePath": "/storage/containers/storage/volumes", | ||||||||
| "transientStore": false | ||||||||
| }, | ||||||||
| "registries": { | ||||||||
| "search": [ | ||||||||
| "registry.fedoraproject.org", | ||||||||
| "registry.access.redhat.com", | ||||||||
| "docker.io" | ||||||||
| ] | ||||||||
| }, | ||||||||
| "plugins": { | ||||||||
| "volume": [ | ||||||||
| "local" | ||||||||
| ], | ||||||||
| "network": [ | ||||||||
| "bridge", | ||||||||
| "macvlan", | ||||||||
| "ipvlan" | ||||||||
| ], | ||||||||
| "log": [ | ||||||||
| "k8s-file", | ||||||||
| "none", | ||||||||
| "passthrough", | ||||||||
| "journald" | ||||||||
| ], | ||||||||
| "authorization": null | ||||||||
| }, | ||||||||
| "version": { | ||||||||
| "APIVersion": "5.5.1", | ||||||||
| "Version": "5.5.1", | ||||||||
| "GoVersion": "go1.23.9", | ||||||||
| "GitCommit": "850db76dd78a0641eddb9ee19ee6f60d2c59bcfa", | ||||||||
| "BuiltTime": "Thu Jun 5 03:00:00 2025", | ||||||||
| "Built": 1749081600, | ||||||||
| "BuildOrigin": "Fedora Project", | ||||||||
| "OsArch": "linux/amd64", | ||||||||
| "Os": "linux" | ||||||||
| } | ||||||||
| } | ||||||||
| """ | ||||||||
|
|
||||||||
| import json | ||||||||
|
|
||||||||
| from ansible.module_utils.basic import AnsibleModule | ||||||||
|
|
||||||||
|
|
||||||||
| def get_podman_system_info(module, executable): | ||||||||
| command = [executable, "system", "info", "--format", "json"] | ||||||||
| rc, out, err = module.run_command(command) | ||||||||
| out = out.strip() | ||||||||
| if out: | ||||||||
| try: | ||||||||
| return json.loads(out) | ||||||||
| except Exception as e: | ||||||||
| module.fail_json( | ||||||||
| msg="Failed to parse podman system info output: error: %s, output: %s err: %s" % (e, out, err), | ||||||||
| exception=str(e), | ||||||||
| ) | ||||||||
|
|
||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
|
|
||||||||
| def main(): | ||||||||
| module = AnsibleModule( | ||||||||
| argument_spec=dict( | ||||||||
| executable=dict(type="str", default="podman"), | ||||||||
| ), | ||||||||
| 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) | ||||||||
|
|
||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
|
|
||||||||
| if __name__ == "__main__": | ||||||||
| main() | ||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| - name: Get Podman system info | ||
| containers.podman.podman_system_info: | ||
| executable: "{{ test_executable | default('podman') }}" | ||
| register: podman_info | ||
|
|
||
| - name: Check results | ||
| assert: | ||
| that: | ||
| - podman_info.podman_system_info | length > 0 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.