community.general/tests/integration/targets/hg/tasks/install.yml
patchback[bot] 0090af8cfb
[PR #10043/2a5abab7 backport][stable-10] Remove blanket skips for Python 3 in CI (#10048)
Remove blanket skips for Python 3 in CI (#10043)

* Remove blanket skips for Python 3 in CI.

* Try to fix hg tests.

* Disable hg tests.

* Drop restriction of supervisor to <4.0.0.

This was introduced in https://github.com/ansible/ansible/pull/54935.

* Make tests work with supervisorctl 4.0.0.

According to https://supervisord.org/changes.html#id12,
"supervisorctl will now set its exit code to a non-zero value when an error condition occurs."
I'm not sure why a stopped service in 'status' constitutes an error condition,
but whatever 🤷...

* Use correct Python executable.

* Skip RHEL/macOS; diff on config write.

* Skip CentOS 7 and OpenSuSE on ansible-core 2.16.

(cherry picked from commit 2a5abab738)

Co-authored-by: Felix Fontein <felix@fontein.de>
2025-04-21 16:34:52 +02:00

99 lines
2.9 KiB
YAML

---
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
- name: get the default python version
command: "{{ ansible_python_interpreter }} -V"
register: default_python_version
- name: find the default python
command: which python
register: which_python
- name: find the default pip
command: which pip
register: which_pip
- name: preserve the default python
command: cp -av "{{ which_python.stdout }}" "{{ which_python.stdout }}.default"
- name: preserve the default pip
command: cp -av "{{ which_pip.stdout }}" "{{ which_pip.stdout }}.default"
# using the apt module prevents autoremove from working, so call apt-get via shell instead
- name: install mercurial (apt)
shell: apt-get -y update && apt-get -y install mercurial
when: ansible_facts.pkg_mgr == 'apt'
- name: install packages (apk)
package:
name: mercurial
state: present
when: ansible_facts.pkg_mgr in ['apk', 'community.general.apk']
- name: install mercurial (dnf)
dnf:
name: mercurial
when: ansible_facts.pkg_mgr == 'dnf'
- name: install mercurial (yum)
yum:
name: mercurial
when: ansible_facts.pkg_mgr == 'yum'
- name: install mercurial (pacman)
package:
name: mercurial
when: ansible_facts.pkg_mgr in ['pacman', 'community.general.pacman']
- name: install mercurial (pkgng)
package:
name: mercurial
when: ansible_facts.pkg_mgr in ['pkgng', 'community.general.pkgng']
- name: install mercurial (zypper)
package:
name: mercurial
when: ansible_facts.pkg_mgr in ['zypper', 'community.general.zypper']
- name: preserve the updated python
command: cp -av "{{ which_python.stdout }}" "{{ which_python.stdout }}.updated"
- name: preserve the updated pip
command: cp -av "{{ which_pip.stdout }}" "{{ which_pip.stdout }}.updated"
- name: locate mercurial
command: which hg
register: which_hg
- name: get the mercurial interpreter
command: head -n 1 "{{ which_hg.stdout }}"
register: hg_interpreter
- name: stat the mercurial interpreter
stat:
path: "{{ hg_interpreter.stdout[2:] }}"
register: stat_hg_interpreter
- name: bypass the mercurial python interpreter symlink (if needed)
lineinfile:
path: "{{ which_hg.stdout }}"
regexp: "^#!.*$"
line: "#!{{ stat_hg_interpreter.stat.lnk_source }}"
when: stat_hg_interpreter.stat.islnk
- name: restore the default python
command: cp -av "{{ which_python.stdout }}.default" "{{ which_python.stdout }}"
- name: restore the default pip
command: cp -av "{{ which_pip.stdout }}.default" "{{ which_pip.stdout }}"
- name: get the current python version
command: "{{ ansible_python_interpreter }} -V"
register: current_python_version
- name: verify the python version has not changed
assert:
that:
- default_python_version.stdout == current_python_version.stdout