]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
refact the 'raw' installation of python
authorGuillaume Abrioux <gabrioux@redhat.com>
Wed, 16 Jan 2019 05:57:02 +0000 (06:57 +0100)
committerSébastien Han <seb@redhat.com>
Wed, 16 Jan 2019 09:16:11 +0000 (10:16 +0100)
to avoid duplicating code in `site.yml.sample`, `site-docker.yml.sample`
and `setup.yml`, let's isolate this part of the code and simply include
it each time we need it.

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
.gitignore
raw_install_python.yml [new file with mode: 0644]
site-container.yml.sample
site.yml.sample
tests/functional/lvm_setup.yml
tests/functional/setup.yml

index c3257576be214f6f1b9c9e52748ada563fed5760..98527d7a392206775a4467d41e2364d4b074e4bc 100644 (file)
@@ -20,3 +20,4 @@ ceph-ansible.spec
 *.pytest_cache
 !.travis.yml
 !.mergify.yml
+!raw_install_python.yml
\ No newline at end of file
diff --git a/raw_install_python.yml b/raw_install_python.yml
new file mode 100644 (file)
index 0000000..28d1a45
--- /dev/null
@@ -0,0 +1,24 @@
+---
+- name: check for python
+  stat:
+    path: /usr/bin/python
+  ignore_errors: yes
+  register: systempython
+
+- name: install python for debian based systems
+  raw: apt-get -y install python-simplejson
+  ignore_errors: yes
+  when:
+    - systempython.stat is undefined or not systempython.stat.exists
+
+- name: install python for fedora
+  raw: dnf -y install python3; ln -sf /usr/bin/python3 /usr/bin/python creates=/usr/bin/python
+  ignore_errors: yes
+  when:
+    - systempython.stat is undefined or not systempython.stat.exists
+
+- name: install python for opensuse
+  raw: zypper -n install python-base creates=/usr/bin/python2.7
+  ignore_errors: yes
+  when:
+    - systempython.stat is undefined or not systempython.stat.exists
\ No newline at end of file
index ee9207b9d7efd0ff029a1c7d5f552168c383629e..117c82b36f3934977c664adcfda63fcda7d46255 100644 (file)
@@ -21,6 +21,9 @@
   vars:
     delegate_facts_host: True
 
+  pre_tasks:
+    - import_tasks: raw_install_python.yml
+
   tasks:
     # pre-tasks for following import -
     - name: gather facts
index 2f7316248fdf0777b2f7a5536138082174bbcd32..2ee2fe8145cee7da58d6dfaf00fdf235ea81e6f8 100644 (file)
   pre_tasks:
     # If we can't get python2 installed before any module is used we will fail
     # so just try what we can to get it installed
-    - name: check for python2
-      stat:
-        path: /usr/bin/python
-      ignore_errors: yes
-      register: systempython2
-
-    - name: install python2 for debian based systems
-      raw: sudo apt-get -y install python-simplejson
-      ignore_errors: yes
-      when:
-        - systempython2.stat is undefined or not systempython2.stat.exists
-
-    - name: install python2 for fedora
-      raw: sudo dnf -y install python creates=/usr/bin/python
-      ignore_errors: yes
-      when:
-        - systempython2.stat is undefined or not systempython2.stat.exists
 
-    - name: install python2 for opensuse
-      raw: sudo zypper -n install python-base creates=/usr/bin/python2.7
-      ignore_errors: yes
-      when:
-        - systempython2.stat is undefined or not systempython2.stat.exists
+    - import_tasks: raw_install_python.yml
 
     - name: gather facts
       setup:
index c87b73914060d0f11cfee3c12e8a35bb70d35cf2..005df31d871f829e5fbc1fa0a4ce515d34aab1a5 100644 (file)
@@ -1,4 +1,9 @@
 ---
+- hosts: all
+  gather_facts: false
+  become: yes
+  tasks:
+    - import_tasks: ../../raw_install_python.yml
 
 - hosts: osds
   gather_facts: false
index 752b0aa30f9fa96e946a23c6606facf2f94ccf85..52f8ebc5ce63516d4cd4cdb6d2acd429838ddd66 100644 (file)
@@ -1,5 +1,4 @@
 ---
-
 - hosts: all
   gather_facts: true
   become: yes