forked from redhat-cop/agnosticd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
post_infra.yml
56 lines (50 loc) · 1.92 KB
/
post_infra.yml
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
---
- name: Build inventory
hosts: localhost
connection: local
become: false
gather_facts: False
tags:
- step002
tasks:
- when: target_host is mapping
block:
- when:
- '"ansible_ssh_private_key_content" in target_host'
- '"ansible_ssh_private_key_file" in target_host'
fail:
msg: You cannot set both ansible_ssh_private_key_content and ansible_ssh_private_key_file
- when: '"ansible_ssh_private_key_content" in target_host'
block:
- name: Prepare ssh_key from provided content
copy:
content: "{{ target_host.ansible_ssh_private_key_content }}"
dest: "{{ output_dir }}/ssh_key.pem"
mode: 0600
- set_fact:
target_host_ansible_ssh_private_key_file: "{{ output_dir }}/ssh_key.pem"
- name: Add bastion to inventory
add_host:
name: >-
{{
target_host.name
| default(target_host.hostname)
| default(target_host.ansible_host)
}}
ansible_host: "{{ target_host.ansible_ssh_host | default(omit) }}"
group: ocp_bastions
ansible_user: "{{ target_host.ansible_user | default(omit) }}"
ansible_port: "{{ target_host.ansible_port | default(omit) }}"
ansible_ssh_private_key_file: >-
{{ target_host.ansible_ssh_private_key_file
| default(target_host_ansible_ssh_private_key_file)
| default(omit) }}
ansible_ssh_extra_args: "{{ target_host.ansible_ssh_extra_args | default(omit) }}"
ansible_ssh_pipelining: true
- when: target_host is string
block:
- name: Add bastion to inventory (simple hostname)
add_host:
name: "{{ target_host }}"
group: ocp_bastions
- import_playbook: ../../include_vars.yml