common: use discovered_interpreter_python fact

in order to use the right binary name when using python cli in command
or shell module.

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
(cherry picked from commit 13815ad3ca)
pull/4348/head
Guillaume Abrioux 2019-08-14 09:56:41 +02:00 committed by mergify[bot]
parent 4b2d13995d
commit 2f77704591
6 changed files with 9 additions and 9 deletions

View File

@ -116,7 +116,7 @@
# 'sleep 5' is not that bad and should be sufficient # 'sleep 5' is not that bad and should be sufficient
- name: verify the monitor is out of the cluster - name: verify the monitor is out of the cluster
shell: | shell: |
{{ container_exec_cmd }} ceph --cluster {{ cluster }} -s -f json | python -c 'import sys, json; print(json.load(sys.stdin)["quorum_names"])' {{ container_exec_cmd }} ceph --cluster {{ cluster }} -s -f json | {{ discovered_interpreter_python }} -c 'import sys, json; print(json.load(sys.stdin)["quorum_names"])'
delegate_to: "{{ mon_host }}" delegate_to: "{{ mon_host }}"
failed_when: false failed_when: false
register: result register: result

View File

@ -106,7 +106,7 @@
- not rolling_update | bool - not rolling_update | bool
block: block:
- name: generate cluster fsid - name: generate cluster fsid
shell: python -c 'import uuid; print(str(uuid.uuid4()))' shell: "{{ discovered_interpreter_python }} -c 'import uuid; print(str(uuid.uuid4()))'"
register: cluster_uuid register: cluster_uuid
delegate_to: "{{ groups[mon_group_name][0] }}" delegate_to: "{{ groups[mon_group_name][0] }}"
run_once: true run_once: true

View File

@ -19,7 +19,7 @@ $DOCKER_EXEC test -S /var/run/ceph/{{ cluster }}-mon.{{ ansible_hostname }}.asok
check_quorum() { check_quorum() {
while [ $RETRIES -ne 0 ]; do while [ $RETRIES -ne 0 ]; do
$DOCKER_EXEC ceph --cluster {{ cluster }} -s --format json | python -c 'import sys, json; exit(0) if "{{ monitor_name }}" in json.load(sys.stdin)["quorum_names"] else exit(1)' && exit 0 $DOCKER_EXEC ceph --cluster {{ cluster }} -s --format json | "{{ discovered_interpreter_python }}" -c 'import sys, json; exit(0) if "{{ monitor_name }}" in json.load(sys.stdin)["quorum_names"] else exit(1)' && exit 0
sleep $DELAY sleep $DELAY
let RETRIES=RETRIES-1 let RETRIES=RETRIES-1
done done

View File

@ -4,12 +4,12 @@ DELAY="{{ handler_health_osd_check_delay }}"
CEPH_CLI="--name client.bootstrap-osd --keyring /var/lib/ceph/bootstrap-osd/{{ cluster }}.keyring --cluster {{ cluster }}" CEPH_CLI="--name client.bootstrap-osd --keyring /var/lib/ceph/bootstrap-osd/{{ cluster }}.keyring --cluster {{ cluster }}"
check_pgs() { check_pgs() {
num_pgs=$($container_exec ceph $CEPH_CLI -s -f json|python -c 'import sys, json; print(json.load(sys.stdin)["pgmap"]["num_pgs"])') num_pgs=$($container_exec ceph $CEPH_CLI -s -f json | "{{ discovered_interpreter_python }}" -c 'import sys, json; print(json.load(sys.stdin)["pgmap"]["num_pgs"])')
if [[ "$num_pgs" == "0" ]]; then if [[ "$num_pgs" == "0" ]]; then
return 0 return 0
fi fi
while [ $RETRIES -ne 0 ]; do while [ $RETRIES -ne 0 ]; do
test "$($container_exec ceph $CEPH_CLI -s -f json | python -c 'import sys, json; print(json.load(sys.stdin)["pgmap"]["num_pgs"])')" -eq "$($container_exec ceph $CEPH_CLI -s -f json | python -c 'import sys, json; print(sum ( [ i["count"] for i in json.load(sys.stdin)["pgmap"]["pgs_by_state"] if "active+clean" in i["state_name"]]))')" test "$($container_exec ceph $CEPH_CLI -s -f json | "{{ discovered_interpreter_python }}" -c 'import sys, json; print(json.load(sys.stdin)["pgmap"]["num_pgs"])')" -eq "$($container_exec ceph $CEPH_CLI -s -f json | "{{ discovered_interpreter_python }}" -c 'import sys, json; print(sum ( [ i["count"] for i in json.load(sys.stdin)["pgmap"]["pgs_by_state"] if "active+clean" in i["state_name"]]))')"
RET=$? RET=$?
test $RET -eq 0 && return 0 test $RET -eq 0 && return 0
sleep $DELAY sleep $DELAY

View File

@ -11,7 +11,7 @@
- name: generate monitor initial keyring - name: generate monitor initial keyring
shell: > shell: >
python -c "import os ; import struct ; {{ discovered_interpreter_python }} -c "import os ; import struct ;
import time; import base64 ; key = os.urandom(16) ; import time; import base64 ; key = os.urandom(16) ;
header = struct.pack('<hiih',1,int(time.time()),0,len(key)) ; header = struct.pack('<hiih',1,int(time.time()),0,len(key)) ;
print(base64.b64encode(header + key).decode())" print(base64.b64encode(header + key).decode())"

View File

@ -1,9 +1,9 @@
--- ---
- name: wait for all osd to be up - name: wait for all osd to be up
shell: > shell: >
test "$({{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }} -s -f json | python -c 'import sys, json; print(json.load(sys.stdin)["osdmap"]["osdmap"]["num_osds"])')" -gt 0 && test "$({{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }} -s -f json | {{ discovered_interpreter_python }} -c 'import sys, json; print(json.load(sys.stdin)["osdmap"]["osdmap"]["num_osds"])')" -gt 0 &&
test "$({{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }} -s -f json | python -c 'import sys, json; print(json.load(sys.stdin)["osdmap"]["osdmap"]["num_osds"])')" = test "$({{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }} -s -f json | {{ discovered_interpreter_python -c 'import sys, json; print(json.load(sys.stdin)["osdmap"]["osdmap"]["num_osds"])')" =
"$({{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }} -s -f json | python -c 'import sys, json; print(json.load(sys.stdin)["osdmap"]["osdmap"]["num_up_osds"])')" "$({{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }} -s -f json | {{ discovered_interpreter_python }} -c 'import sys, json; print(json.load(sys.stdin)["osdmap"]["osdmap"]["num_up_osds"])')"
register: wait_for_all_osds_up register: wait_for_all_osds_up
retries: "{{ nb_retry_wait_osd_up }}" retries: "{{ nb_retry_wait_osd_up }}"
delay: "{{ delay_wait_osd_up }}" delay: "{{ delay_wait_osd_up }}"