summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2020-04-23 04:59:13 +0200
committerChristian Pointner <equinox@spreadspace.org>2020-04-23 04:59:13 +0200
commit9d9d4fdc70ec0ac276f3795f5ccea39d6b94b995 (patch)
tree72ebbbbb00cfea15039663a765c8372a8b3c04e9 /common
parentrefactor all install roles ans playbooks to work with new variable install_ho... (diff)
further cleanup host bootstraping
Diffstat (limited to 'common')
-rw-r--r--common/cloud-install.yml8
-rw-r--r--common/utils.sh4
-rw-r--r--common/vm-install.yml8
3 files changed, 16 insertions, 4 deletions
diff --git a/common/cloud-install.yml b/common/cloud-install.yml
index 57ebc9e6..e21d4bf1 100644
--- a/common/cloud-install.yml
+++ b/common/cloud-install.yml
@@ -29,7 +29,13 @@
roles:
- role: cloud/post-install
-- import_playbook: "../{{ install_environment }}/{{ hostvars[install_hostname].install_playbook | default(install_hostname) }}.yml"
+- name: run host playbook
+ vars:
+ params:
+ files:
+ - "../{{ install_environment }}/{{ install_hostname }}.yml"
+ - "../{{ install_environment }}/{{ install_playbook | default('common') }}.yml"
+ import_playbook: "{{ q('first_found', params) | first }}"
- name: reboot and wait for machine come back
hosts: "{{ install_hostname }}"
diff --git a/common/utils.sh b/common/utils.sh
index 262926c7..bb14381e 100644
--- a/common/utils.sh
+++ b/common/utils.sh
@@ -19,8 +19,8 @@ ansible_variable__get() {
local _var_name="$1"
local _hosts="$2"
- local _result=$(env ANSIBLE_STDOUT_CALLBACK="json" ansible "$_hosts" -m debug -a "var=$_var_name" | \
- jq -r ".plays[].tasks[].hosts[].$_var_name" | sort | uniq)
+ local _result=$(env ANSIBLE_STDOUT_CALLBACK="json" ansible "$_hosts" -m debug -a "msg={{ $_var_name }}" | \
+ jq -r '.plays[].tasks[].hosts[] | select(.failed != true) | .msg' | sort | uniq)
if [ $? -ne 0 ] || [ -z "$_result" ]; then
print_error "failed to get value of variable '$_var_name' for host(s) '$_hosts'"
return 1
diff --git a/common/vm-install.yml b/common/vm-install.yml
index c3e7a25c..d449926e 100644
--- a/common/vm-install.yml
+++ b/common/vm-install.yml
@@ -58,7 +58,13 @@
- role: vm/guest
when: install_distro in ['debian', 'ubuntu']
-- import_playbook: "../{{ install_environment }}/{{ hostvars[install_hostname].install_playbook | default(install_hostname) }}.yml"
+- name: run host playbook
+ vars:
+ params:
+ files:
+ - "../{{ install_environment }}/{{ install_hostname }}.yml"
+ - "../{{ install_environment }}/{{ install_playbook | default('common') }}.yml"
+ import_playbook: "{{ q('first_found', params) | first }}"
- name: reboot and wait for VM come back
hosts: "{{ install_hostname }}"