forked from ansible/ansible
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable hg test on Python 3. (ansible#35884)
* Enable hg test on Python 3. * Install/uninstall mercurial during test as needed.
- Loading branch information
Showing
4 changed files
with
133 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,2 +1 @@ | ||
posix/ci/group2 | ||
skip/python3 |
This file contains 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,78 @@ | ||
- 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_pkg_mgr == 'apt' | ||
|
||
- name: install mercurial (dnf) | ||
dnf: | ||
name: mercurial | ||
when: ansible_pkg_mgr == 'dnf' | ||
|
||
- name: install mercurial (yum) | ||
yum: | ||
name: mercurial | ||
when: ansible_pkg_mgr == 'yum' | ||
|
||
- name: install mercurial (pkgng) | ||
pkgng: | ||
name: mercurial | ||
when: ansible_pkg_mgr == 'pkgng' | ||
|
||
- 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 |
This file contains 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
This file contains 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,42 @@ | ||
- name: restore the updated python | ||
command: mv "{{ which_python.stdout }}.updated" "{{ which_python.stdout }}" | ||
|
||
- name: restore the updated pip | ||
command: mv "{{ which_pip.stdout }}.updated" "{{ which_pip.stdout }}" | ||
|
||
- name: restore the mercurial python interpreter symlink (if needed) | ||
lineinfile: | ||
path: "{{ which_hg.stdout }}" | ||
regexp: "^#!.*$" | ||
line: "#!{{ stat_hg_interpreter.stat.path }}" | ||
when: stat_hg_interpreter.stat.islnk | ||
|
||
# using the apt module prevents autoremove from working, so call apt-get via shell instead | ||
- name: uninstall packages which were not originally installed (apt) | ||
shell: apt-get -y remove mercurial && apt-get -y autoremove | ||
when: ansible_pkg_mgr == 'apt' | ||
|
||
- name: uninstall packages which were not originally installed (dnf) | ||
dnf: | ||
name: mercurial | ||
state: absent | ||
autoremove: yes | ||
when: ansible_pkg_mgr == 'dnf' | ||
|
||
# the yum module does not have an autoremove parameter | ||
- name: uninstall packages which were not originally installed (yum) | ||
shell: yum -y autoremove mercurial | ||
when: ansible_pkg_mgr == 'yum' | ||
|
||
- name: uninstall packages which were not originally installed (pkgng) | ||
pkgng: | ||
name: mercurial | ||
state: absent | ||
autoremove: yes | ||
when: ansible_pkg_mgr == 'pkgng' | ||
|
||
- name: restore the default python | ||
raw: mv "{{ which_python.stdout }}.default" "{{ which_python.stdout }}" | ||
|
||
- name: restore the default pip | ||
raw: mv "{{ which_pip.stdout }}.default" "{{ which_pip.stdout }}" |