-
Notifications
You must be signed in to change notification settings - Fork 0
/
pre.yml
35 lines (33 loc) · 988 Bytes
/
pre.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
- name: Change key file permissions
hosts: localhost
gather_facts: no
tasks:
- file:
path: "{{ provision.host.key }}"
state: touch
mode: 0600
when: provision.host.key
- name: clean old inventory file
hosts: localhost
gather_facts: no
tasks:
- file:
dest: "{{ inventory_dir }}/hosts"
state: link
src: "local_hosts"
- name: Add host to host list
hosts: localhost
gather_facts: yes
tags: always
vars:
hypervisor: "{{ provision.host }}"
hypervisor_name: hypervisor
tasks:
- name: add hosts to host list
add_host:
name: "{{ hypervisor.name | default(hypervisor_name) }}"
groups: "{{ hypervisor.groups|default([hypervisor_name]) | join(',') }}"
ansible_user: "{{ hypervisor.user }}"
ansible_host: "{{ hypervisor.address }}"
ansible_ssh_private_key_file: "{{ hypervisor.key }}"
inventory_dir: "{{ inventory_dir }}"