Skip to content

Added install-ansible module - #158

Merged
craigcomstock merged 6 commits into
cfengine:masterfrom
craigcomstock:ent-14328
Aug 20, 2026
Merged

Added install-ansible module#158
craigcomstock merged 6 commits into
cfengine:masterfrom
craigcomstock:ent-14328

Conversation

@craigcomstock

Copy link
Copy Markdown
Contributor

Ticket: none
Changelog: none

@craigcomstock
craigcomstock force-pushed the ent-14328 branch 2 times, most recently from 7800ff0 to 13b4ed6 Compare August 20, 2026 18:53
@craigcomstock
craigcomstock marked this pull request as ready for review August 20, 2026 18:54

@nickanderson nickanderson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There are a couple classes promises that I think should be guarded.

Did you try using packages promises for pipx and hit a wall?

Comment thread inventory/inventory-smartctl/policy.cf Outdated
"_cache_ttl" string => "3600";

# 1 hour
# 1 hour

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What is 1 hour?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Was there before ... Would have to research, was a formatting change needed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

1 hour is a comment that got formatted away from the cache_ttl 3600 above.


# 1 hour
# 1 hour
linux._have_smartctl::

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Probably could just be _have_smartctl::

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, was preserving existing as much as possible.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The rest of the policy uses the linux class guard as well, often. I think probably we should not change that.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

yeah, it also really wants to be able to have a default context.

Comment thread software/install-ansible.cf Outdated
#
# host specific data supported, in the data bundle context
#
# ansible_installed: class, if defined, installed ansible

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

below you are keying off of data:install_ansible I would specify it the same here. When I see a class without a namespace, I assume the class is expected to be in the default namespace.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Doc rot as usual, will fix.

Comment thread software/install-ansible.cf Outdated
Comment on lines +6 to +7
# ansible_minimal_install: class, if defined, minimal install aka ansible-core
# ansible_full_install: class, if defined, full install. This is the default if neither minimal or full classes are defined.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

same, I would call out the namespace explicitly here.

Comment thread software/install-ansible.cf Outdated
Comment on lines +15 to +19
windows::
"Use WSL to install Ansible on Windows. See https://blog.rolpdog.com/2020/03/why-no-ansible-controller-for-windows.html";

!linux::
"Installing Ansible on a non-Linux host is not currently supported";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe swap the order so that the reports come out saying installing ansible on non liux isnt supported and then emits the instruction for installing on windows.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Will make them separate, windows and not windows or Linux aka other unix.

Comment on lines +47 to +50
pipx_installed.!ansible_installed::
"${install_ansible_command}"
contain => in_shell_umask(022),
comment => "The default umask of 077 would create /opt/pipx/venvs/ansible which is inaccessible to everyone but root, so use 022 instead.";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I guess the old pip package methods don't work well for this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not sure. I didn't want to implement a pipx package module so went this route instead.

Comment thread software/install-ansible.cf Outdated
Comment on lines +52 to +54
reports:
ansible_installed::
"ansible_installed";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would delete this report before shipping.

Comment thread software/install-pipx.cf Outdated
Comment on lines +8 to +12
windows::
"Use WSL to install software";

!linux::
"Installing Ansible on a non-Linux host is not currently supported";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe reverse the order of reports so it says not supported and then tells how to install on windows?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Will make them windows and other unixes.

Comment thread software/install-pipx.cf Outdated
Comment on lines +18 to +19
"pipx_installed"
expression => returnszero("command -v pipx >/dev/null", "useshell");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Guard this on linux:: to avoid execution on non-linux cause pre-eval

Comment thread software/install-pipx.cf Outdated
"/opt/pipx/venvs"
perms => mog("755", "root", "root"),
depth_search => recurse_with_base("1"),
comment => "/opt/pipx/venvs in some cases will be 700 which prevents non-root users from running installed commands.";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Curious about those cases. Is that specific platform?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Saw it on alpine, will test on debian.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This was a side-effect of running pipx install with a commands promise with default umask. When changing the umask to something more "normal", 022, things are OK without this so will remove. I tested debian and alpine and neither creates /opt/pipx or /opt/pipx/venvs when just installing the pipx package, only when using pipx to install.

Added shell deploy test to ensure pipx and ansible are installed according to specific classes for minimal vs full install and specific version of ansible.

Ticket: ENT-14328
@craigcomstock craigcomstock changed the title Added install-ansible and install-pipx modules Added install-ansible module Aug 20, 2026
@craigcomstock
craigcomstock merged commit 28790a3 into cfengine:master Aug 20, 2026
10 checks passed
@craigcomstock
craigcomstock deleted the ent-14328 branch August 20, 2026 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants