Browse Source

Allow the role to only configure pip, not install it

There are times when you may wish to just configure pip,
not install it. This adds a flag to enable that option.

Change-Id: Ibaa3c0b6b323f22dbd640562362106166bbc0a0a
Jesse Pretorius 8 months ago
parent
commit
79e3480a68
3 changed files with 26 additions and 22 deletions
  1. 6
    0
      defaults/main.yml
  2. 17
    0
      tasks/install.yml
  3. 3
    22
      tasks/main.yml

+ 6
- 0
defaults/main.yml View File

@@ -57,6 +57,12 @@ cache_timeout: 600
57 57
 # is intercepting the certificates.
58 58
 pip_validate_certs: "yes"
59 59
 
60
+# Boolean variable to set whether the role should
61
+# install pip if it is found to be missing. There
62
+# are times when you may just want to only configure
63
+# pip, instead of also installing it.
64
+pip_install: true
65
+
60 66
 # Boolean variable to set whether pip.conf should be
61 67
 # implemented to adjust pip's default behaviour.
62 68
 # By default we do this, but sometimes we want to

tasks/pre_install.yml → tasks/install.yml View File

@@ -21,3 +21,20 @@
21 21
   until: install_packages is success
22 22
   retries: 5
23 23
   delay: 2
24
+
25
+- name: Determine PIP installation script
26
+  shell: >
27
+    if [[ $(set -o pipefail; pip --version 2>/dev/null | awk '{print $2}' | cut -d. -f1) -ge 7 ]]; then
28
+        echo "$(which pip) install --upgrade"
29
+    else
30
+        echo "python /opt/get-pip.py"
31
+    fi
32
+  args:
33
+    executable: /bin/bash
34
+  register: pip_install_script
35
+  changed_when: False
36
+
37
+- include_tasks: "install_{{ pip_offline_install | ternary('offline', 'online') }}.yml"
38
+  when: pip_install_script.find('get-pip.py') != -1 # skip get-pip.py if a suitable pip is installed
39
+
40
+- include_tasks: install_source.yml

+ 3
- 22
tasks/main.yml View File

@@ -30,27 +30,8 @@
30 30
   tags:
31 31
     - pip_install-config
32 32
 
33
-- include_tasks: pre_install.yml
34
-  tags:
35
-    - pip_install-install
36
-
37
-- name: Determine PIP installation script
38
-  shell: >
39
-    if [[ $(set -o pipefail; pip --version 2>/dev/null | awk '{print $2}' | cut -d. -f1) -ge 7 ]]; then
40
-        echo "$(which pip) install --upgrade"
41
-    else
42
-        echo "python /opt/get-pip.py"
43
-    fi
44
-  args:
45
-    executable: /bin/bash
46
-  register: pip_install_script
47
-  changed_when: False
48
-
49
-- include_tasks: "install_{{ pip_offline_install | ternary('offline', 'online') }}.yml"
50
-  tags:
51
-    - pip_install-install
52
-  when: pip_install_script.stdout.find('get-pip.py') != -1 # skip get-pip.py if a suitable pip is installed
53
-
54
-- include_tasks: install_source.yml
33
+- include_tasks: install.yml
34
+  when:
35
+    - pip_install | bool
55 36
   tags:
56 37
     - pip_install-install

Loading…
Cancel
Save