-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexercise9-break.yaml
More file actions
59 lines (52 loc) · 1.58 KB
/
exercise9-break.yaml
File metadata and controls
59 lines (52 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
---
- name: Preparing the exercise9
hosts: localhost
gather_facts: true
vars:
user: "{{ lookup('env', 'USER') }}"
tasks:
- name: Create SSH config file with StrictHostKeyChecking no
ansible.builtin.copy:
dest: '/home/{{ user }}/.ssh/config'
content: |
Host *
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
owner: '{{ user }}'
group: '{{ user }}'
mode: '0600'
- name: Read the content of the file
ansible.builtin.slurp:
src: '/home/{{ user }}/.ssh/id_rsa.pub'
register: idrsapub
- name: Store base64 encoded content in a variable
ansible.builtin.set_fact:
encodedsshpubkey: "{{ idrsapub.content }}"
- name: Create the idrsa secret
kubernetes.core.k8s:
state: present
template: "exercise9-secret.yaml.j2"
register: secretidrsa
until: secretidrsa is succeeded
retries: 60
delay: 10
failed_when: secretidrsa is failed or secretidrsa.failed
- name: Creating the exercise9 virtual machine
kubernetes.core.k8s:
state: present
template: "exercise9-vm.yaml.j2"
register: breakvm
until: breakvm is succeeded
retries: 60
delay: 10
failed_when: breakvm is failed or breakvm.failed
- name: Wait for exercise9
ansible.builtin.command:
cmd: virtctl ssh -i /home/{{ user }}/.ssh/id_rsa lab-user@exercise9
ignore_errors: true
no_log: false
register: testssh
until:
- testssh.rc == 0
retries: 20
delay: 10