Debian Codegraph @

ansible_collections/community/general/tests/integration/targets/hg/tasks/install.yml

raw
1 ---
2 # Copyright (c) Ansible Project
3 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
4 # SPDX-License-Identifier: GPL-3.0-or-later
5
6 - name: get the default python version
7 command: "{{ ansible_python_interpreter }} -V"
8 register: default_python_version
9
10 - name: find the default python
11 command: which python
12 register: which_python
13
14 - name: find the default pip
15 command: which pip
16 register: which_pip
17
18 - name: preserve the default python
19 command: cp -av "{{ which_python.stdout }}" "{{ which_python.stdout }}.default"
20
21 - name: preserve the default pip
22 command: cp -av "{{ which_pip.stdout }}" "{{ which_pip.stdout }}.default"
23
24 # using the apt module prevents autoremove from working, so call apt-get via shell instead
25 - name: install mercurial (apt)
26 shell: apt-get -y update && apt-get -y install mercurial
27 when: ansible_facts.pkg_mgr == 'apt'
28
29 - name: install mercurial package
30 package:
31 name: mercurial
32 state: present
33 when: ansible_facts.pkg_mgr in ['apk', 'community.general.apk', 'pacman', 'community.general.pacman', 'pkgng', 'community.general.pkgng', 'zypper', 'community.general.zypper']
34
35 - name: install mercurial (dnf)
36 dnf:
37 name: mercurial
38 when: ansible_facts.pkg_mgr == 'dnf'
39
40 - name: install mercurial (yum)
41 yum:
42 name: mercurial
43 when: ansible_facts.pkg_mgr == 'yum'
44
45 - name: preserve the updated python
46 command: cp -av "{{ which_python.stdout }}" "{{ which_python.stdout }}.updated"
47
48 - name: preserve the updated pip
49 command: cp -av "{{ which_pip.stdout }}" "{{ which_pip.stdout }}.updated"
50
51 - name: locate mercurial
52 command: which hg
53 register: which_hg
54
55 - name: get the mercurial interpreter
56 command: head -n 1 "{{ which_hg.stdout }}"
57 register: hg_interpreter
58
59 - name: stat the mercurial interpreter
60 stat:
61 path: "{{ hg_interpreter.stdout[2:] }}"
62 register: stat_hg_interpreter
63
64 - name: bypass the mercurial python interpreter symlink (if needed)
65 lineinfile:
66 path: "{{ which_hg.stdout }}"
67 regexp: "^#!.*$"
68 line: "#!{{ stat_hg_interpreter.stat.lnk_source }}"
69 when: stat_hg_interpreter.stat.islnk
70
71 - name: restore the default python
72 command: cp -av "{{ which_python.stdout }}.default" "{{ which_python.stdout }}"
73
74 - name: restore the default pip
75 command: cp -av "{{ which_pip.stdout }}.default" "{{ which_pip.stdout }}"
76
77 - name: get the current python version
78 command: "{{ ansible_python_interpreter }} -V"
79 register: current_python_version
80
81 - name: verify the python version has not changed
82 assert:
83 that:
84 - default_python_version.stdout == current_python_version.stdout