summaryrefslogtreecommitdiffstats
path: root/ansible/deployment_poc
diff options
context:
space:
mode:
authorGeorg Pfuetzenreuter2022-02-14 00:32:26 +0100
committerGeorg Pfuetzenreuter2022-02-14 00:32:26 +0100
commit7e55910b27e877574e518fa1febc32405b129171 (patch)
treef23bb27b9cd7f0591ae7fc9dfc98bc1ac29fc0b0 /ansible/deployment_poc
parent2ce8450b893ad9f8a119a1ff24dcc7eb4ba78b82 (diff)
downloadsystem-7e55910b27e877574e518fa1febc32405b129171.tar.gz
system-7e55910b27e877574e518fa1febc32405b129171.tar.bz2
system-7e55910b27e877574e518fa1febc32405b129171.zip
Deployment PoC - Add pexpect supervision
Signed-off-by: Georg Pfuetzenreuter <georg@lysergic.dev>
Diffstat (limited to 'ansible/deployment_poc')
-rw-r--r--ansible/deployment_poc/playbooks/deploy.yml4
-rw-r--r--ansible/deployment_poc/tasks/autoyast_assistant.yml38
-rw-r--r--ansible/deployment_poc/tasks/init_ssh.yml1
-rw-r--r--ansible/deployment_poc/tasks/init_vm_console.yml1
-rw-r--r--ansible/deployment_poc/tasks/wait.yml48
5 files changed, 82 insertions, 10 deletions
diff --git a/ansible/deployment_poc/playbooks/deploy.yml b/ansible/deployment_poc/playbooks/deploy.yml
index 4009b26..7650737 100644
--- a/ansible/deployment_poc/playbooks/deploy.yml
+++ b/ansible/deployment_poc/playbooks/deploy.yml
@@ -99,6 +99,7 @@
block:
- import_tasks: "../tasks/netbox_init_ip.yml"
- import_tasks: "../tasks/netbox_primaryip.yml"
+ no_log: true
- name: Start VM and attach console
import_tasks: "../tasks/init_vm_console.yml"
@@ -106,6 +107,9 @@
- name: Initialize SSH CA
import_tasks: "../tasks/init_ssh.yml"
+ - name: Assist guest OS installation
+ import_tasks: "../tasks/autoyast_assistant.yml"
+
- name: Wait for guest OS installation
import_tasks: "../tasks/wait.yml"
diff --git a/ansible/deployment_poc/tasks/autoyast_assistant.yml b/ansible/deployment_poc/tasks/autoyast_assistant.yml
new file mode 100644
index 0000000..7a7542a
--- /dev/null
+++ b/ansible/deployment_poc/tasks/autoyast_assistant.yml
@@ -0,0 +1,38 @@
+---
+- name: Monitor OS installation
+ block:
+ - name: Monitor first stage
+ ansible.builtin.expect:
+ command: "/usr/bin/virsh -c {{ libvirt_url }} console {{ vm_name }} --force"
+ responses:
+ "reboot: Restarting system":
+ - "\u001d"
+ timeout: 720
+ ignore_errors: true
+ no_log: true
+
+ - name: Destroy
+ community.libvirt.virt:
+ uri: "{{ libvirt_url }}"
+ command: destroy
+ name: "{{ vm_name }}"
+ state: destroyed
+
+ - name: Start
+ community.libvirt.virt:
+ uri: "{{ libvirt_url }}"
+ command: start
+ name: "{{ vm_name }}"
+ state: running
+
+ - name: Unlock
+ ansible.builtin.expect:
+ command: "/usr/bin/virsh -c {{ libvirt_url }} console {{ vm_name }} --force"
+ responses:
+ "Please enter passphrase for disk cr_root:":
+ - "{{ luks_passphrase }}"
+ - "\u001d"
+ ignore_errors: yes
+ no_log: true
+
+ delegate_to: localhost
diff --git a/ansible/deployment_poc/tasks/init_ssh.yml b/ansible/deployment_poc/tasks/init_ssh.yml
index 386c517..6dbc5cf 100644
--- a/ansible/deployment_poc/tasks/init_ssh.yml
+++ b/ansible/deployment_poc/tasks/init_ssh.yml
@@ -48,6 +48,7 @@
get_attributes: no
register: stat_ssh_spk
+ no_log: true
delegate_to: localhost
tags:
- init_ssh
diff --git a/ansible/deployment_poc/tasks/init_vm_console.yml b/ansible/deployment_poc/tasks/init_vm_console.yml
index a74fde6..5b1c614 100644
--- a/ansible/deployment_poc/tasks/init_vm_console.yml
+++ b/ansible/deployment_poc/tasks/init_vm_console.yml
@@ -18,6 +18,7 @@
- -d
- -s
- "{{ vm_name }}"
+ ignore_errors: true
- name: Attach console inside tmux
ansible.builtin.command:
diff --git a/ansible/deployment_poc/tasks/wait.yml b/ansible/deployment_poc/tasks/wait.yml
index 7d516ce..4553a76 100644
--- a/ansible/deployment_poc/tasks/wait.yml
+++ b/ansible/deployment_poc/tasks/wait.yml
@@ -1,14 +1,42 @@
---
-- name: Wait for guest to become alive
- wait_for:
- #delay: 240
- connect_timeout: 3
- sleep: 15
- port: 22
- host: '{{ ip_address }}'
- search_regex: OpenSSH
- timeout: 900
- #connection: local
+- name: Sit patiently
+ block:
+ - name: Wait for guest to become alive
+ wait_for:
+ delay: 240
+ connect_timeout: 3
+ sleep: 15
+ port: 22
+ host: '{{ ip_address }}'
+ search_regex: OpenSSH
+ timeout: 600
+
+# rescue:
+# - name: Destroy
+# community.libvirt.virt:
+# uri: "{{ libvirt_url }}"
+# command: destroy
+# name: "{{ vm_name }}"
+# state: destroyed
+#
+# - name: Start
+# community.libvirt.virt:
+# uri: "{{ libvirt_url }}"
+# command: start
+# name: "{{ vm_name }}"
+# state: running
+#
+# - name: Wait for guest to become alive
+# wait_for:
+# delay: 120
+# connect_timeout: 3
+# sleep: 15
+# port: 22
+# host: '{{ ip_address }}'
+# search_regex: OpenSSH
+# timeout: 600
+
delegate_to: localhost
tags:
- init_ssh
+