Skip to content

Conversation

@johnsonlien
Copy link
Contributor

@johnsonlien johnsonlien commented Apr 8, 2025

This adds the podman_system_info module. There are niche use cases in offline environments to set up machines running Podman.

Closes #921

@johnsonlien johnsonlien force-pushed the add-podman_system_info-module branch from e40c22c to 22d8381 Compare April 8, 2025 05:38
Copy link
Contributor Author

@johnsonlien johnsonlien left a comment

Choose a reason for hiding this comment

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

Have come into (rare) situations where I needed to configure cgroups to use v2 or network backend. This can help my playbook to decide whether or not to do those extra steps.

@sshnaidm
Copy link
Member

Awesome! Thanks for this addition.
Please integrate CI tests as done in its example so tests can run inside the job: #531

Copy link
Contributor Author

@johnsonlien johnsonlien left a comment

Choose a reason for hiding this comment

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

added workflow

@johnsonlien johnsonlien force-pushed the add-podman_system_info-module branch from 3296a37 to 47f94ea Compare April 15, 2025 06:26
@sshnaidm
Copy link
Member

  1. You need to add all from that PR, this file as well: https://github.com/containers/ansible-podman-collections/pull/531/files#diff-a01ddc89899bc0839a7c238e1a66c67a6087d5d8954f4729b22e64cff76cd21a
  2. Need to fix linter and ansible-test:
ERROR: Found 3 yamllint issue(s) which need to be resolved:
ERROR: plugins/modules/podman_system_info.py:26:1: error: EXAMPLES: syntax error: found unexpected end of stream (syntax)
ERROR: plugins/modules/podman_system_info.py:26:1: unparsable-with-libyaml: EXAMPLES: while scanning a quoted scalar found unexpected end of stream
ERROR: plugins/modules/podman_system_info.py:50:1: error: RETURN: syntax error: found character '\t' that cannot start any token (syntax)

ERROR: plugins/modules/podman_system_info.py:0:0: undocumented-parameter: Argument 'executable' is listed in the argument_spec, but not documented in the module documentation
ERROR: plugins/modules/podman_system_info.py:26:1: invalid-examples: EXAMPLES is not valid YAML
RROR: plugins/modules/podman_system_info.py:0:0: doc-default-does-not-match-spec: Argument 'executable' in argument_spec defines default as ('podman') but documentation defines default as (None)
ERROR: plugins/modules/podman_system_info.py:0:0: parameter-type-not-in-doc: Argument 'executable' in argument_spec defines type as 'str' but documentation doesn't define type

  1. And RETURN statement should be YAML, take a look at example here: https://github.com/containers/ansible-podman-collections/blob/main/plugins/modules/podman_container_info.py#L51

Signed-off-by: johnsonlien <[email protected]>
Signed-off-by: johnsonlien <[email protected]>
Signed-off-by: johnsonlien <[email protected]>
Signed-off-by: johnsonlien <[email protected]>
return json object and add example for printing value

Signed-off-by: johnsonlien <[email protected]>
Signed-off-by: johnsonlien <[email protected]>
@johnsonlien johnsonlien force-pushed the add-podman_system_info-module branch from 1636a59 to 1c857fe Compare April 16, 2025 05:59
@johnsonlien johnsonlien force-pushed the add-podman_system_info-module branch from be7f23e to b576ca5 Compare April 16, 2025 06:28
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'] }}"

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
}

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

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.

ekohl and others added 19 commits April 28, 2025 22:21
For quadlets you can set sdnotify (which maps to Notify=) to healthy to
use a healthcheck to determine when the container is up.

Signed-off-by: Ewoud Kohl van Wijngaarden <[email protected]>
Signed-off-by: johnsonlien <[email protected]>
Signed-off-by: johnsonlien <[email protected]>
Signed-off-by: johnsonlien <[email protected]>
Signed-off-by: johnsonlien <[email protected]>
Signed-off-by: johnsonlien <[email protected]>
return json object and add example for printing value

Signed-off-by: johnsonlien <[email protected]>
Signed-off-by: johnsonlien <[email protected]>
Signed-off-by: johnsonlien <[email protected]>
Signed-off-by: johnsonlien <[email protected]>
Fix containers#917
Signed-off-by: Sagi Shnaidman <[email protected]>
Signed-off-by: johnsonlien <[email protected]>
Signed-off-by: Sagi Shnaidman <[email protected]>
Signed-off-by: johnsonlien <[email protected]>
Copy link
Member

@sshnaidm sshnaidm left a comment

Choose a reason for hiding this comment

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

Please fix remaining issues and should be fine

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


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

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.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

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

package: conmon-2.0.29-2.fc34.x86_64
path: /usr/bin/conmon
version: 'conmon version 2.0.29, commit: '
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

@sshnaidm
Copy link
Member

sshnaidm commented Apr 29, 2025

pep8 errors, included in suggestions:

ERROR: Found 3 pep8 issue(s) which need to be resolved:
ERROR: plugins/modules/podman_system_info.py:187:1: E302: expected 2 blank lines, found 1
ERROR: plugins/modules/podman_system_info.py:197:1: E302: expected 2 blank lines, found 1
ERROR: plugins/modules/podman_system_info.py:216:1: E305: expected 2 blank lines after class or function definition, found 1

@sshnaidm
Copy link
Member

@johnsonlien would you like to fix these last linter errors?

@sshnaidm sshnaidm force-pushed the add-podman_system_info-module branch 4 times, most recently from 2dd7cfe to 93fa2d1 Compare June 22, 2025 10:06
Signed-off-by: Sagi Shnaidman <[email protected]>
@sshnaidm sshnaidm force-pushed the add-podman_system_info-module branch from 93fa2d1 to 9aa5d9c Compare June 22, 2025 10:09
@sshnaidm sshnaidm merged commit aa20ede into containers:main Jun 22, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add module podman_system_info

7 participants