Skip to content
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

Fedora - Use new auto ansible_python_interpreter for dnf #239

Merged
merged 8 commits into from
Oct 25, 2019
Merged

Fedora - Use new auto ansible_python_interpreter for dnf #239

merged 8 commits into from
Oct 25, 2019

Conversation

jaredledvina
Copy link
Contributor

Docs: https://docs.ansible.com/ansible/latest/reference_appendices/interpreter_discovery.html

Noticed this in https://travis-ci.org/dev-sec/ansible-os-hardening/jobs/597153020, looks like Ansible can't find python2-dnf and thus Fedora is angry. Some digging found ansible/ansible#49362 (comment) which makes sense to me.

This is a quick attempt to configure ansible_python_interpreter to use the newer auto setting, which should be the new default in 2.12 just for Fedora.

Opening this to verify the TravisCI build passes. If so, good to merge!

Signed-off-by: Jared Ledvina <jared@techsmix.net>
@jaredledvina
Copy link
Contributor Author

Hrm, nope...would need to pass that env through to the container. Going to try another approach.

Signed-off-by: Jared Ledvina <jared@techsmix.net>
Signed-off-by: Jared Ledvina <jared@techsmix.net>
@jaredledvina
Copy link
Contributor Author

jaredledvina commented Oct 15, 2019

Hrm, so, the Docker images are using a few different Ansible versions it seems.

  • CentOS 6: 2.7.9
  • OracleLinux 6: 2.6.17
  • Everyone else: 2.8.5

This is a feature added in 2.8 - https://github.com/ansible/ansible/blob/stable-2.8/changelogs/CHANGELOG-v2.8.rst#major-changes, so we'd either need to upgrade the Docker images to use at least 2.8 (which is probably worth it regardless) or be more clever.

EDIT:

Digging in further I see that the CentOS 6 image is configured to install Ansible from https://releases.ansible.com/ansible/rpm/release/epel-6-x86_64/ which is in-fact missing a 2.8 RPM. OracleLinux 6 uses https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm to configure EPEL and I think, because it only has Python 2.6, ends up w/ the latest Ansible 2.6 release.

Darn.....

@@ -64,6 +64,9 @@ script:
# Run container in detached state.
- 'docker run --detach --volume="${PWD}":/etc/ansible/roles/ansible-os-hardening:ro ${run_opts} rndmh3ro/docker-${distro}-ansible:${version} "${init}" > "${container_id}"'

# Output Ansible version from docker image
Copy link
Member

Choose a reason for hiding this comment

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

Good idea!

@rndmh3ro
Copy link
Member

Hey @jaredledvina,

thanks for your PR!

Digging in further I see that the CentOS 6 image is configured to install Ansible from https://releases.ansible.com/ansible/rpm/release/epel-6-x86_64/ which is in-fact missing a 2.8 RPM. OracleLinux 6 uses https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm to configure EPEL and I think, because it only has Python 2.6, ends up w/ the latest Ansible 2.6 release.

This is exactly the problem.. I'm hesitant to require Ansible 2.8 on these systems because of this. I personally realy on using the packaged versions on these systems and don't want to mingle with pip there.

What we could try here is to set the fact with a pre_task if ansible is in version 2.8 or greater:

    - name: set ansible_python_interpreter to auto on systems with ansible 2.8
      set_fact:                                                                                
        ansible_python_interpreter: "auto"
      when: ansible_version.full is version('2.8', '>')

@rndmh3ro rndmh3ro merged commit d609de1 into dev-sec:master Oct 25, 2019
@jaredledvina jaredledvina deleted the feature/fixup-fedora-tests branch October 25, 2019 23:08
divialth pushed a commit to divialth/ansible-collection-hardening that referenced this pull request Aug 3, 2022
* Fedora - Use new  ansible_python_interpreter for dnf

Signed-off-by: Jared Ledvina <jared@techsmix.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants