-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.yml
69 lines (64 loc) · 2 KB
/
main.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
57
58
59
60
61
62
63
64
65
66
67
68
69
---
- name: config as code demo for AAP
hosts: controller
gather_facts: false
vars:
controller_user: code
controller_pass: codepassword
tasks:
- name: bring in credentials variables
include_vars:
file: cred.yml
run_once: true
- name: manage credentials
ansible.controller.credential:
controller_host: "https://{{ ansible_host }}"
controller_username: "{{ controller_user }}"
controller_password: "{{ controller_pass }}"
name: "{{ item.name }}"
organization: "{{ item.org }}"
description: Added by automation
credential_type: "{{ item.type }}"
state: "{{ item.state }}"
inputs:
# secret key
password: "{{ item.password }}"
# access key
username: "{{ item.username }}"
validate_certs: false
loop: "{{ creds }}"
- name: bring in inventory variables
include_vars:
file: inventory.yml
run_once: true
- name: manage inventories
ansible.controller.inventory:
controller_host: "https://{{ ansible_host }}"
controller_username: "{{ controller_user }}"
controller_password: "{{ controller_pass }}"
name: "{{ item.name }}"
description: Added by automation
state: "{{ item.state }}"
organization: "{{ item.org }}"
validate_certs: false
loop: "{{ inv_var }}"
- name: bring in inventory source variables
include_vars:
file: inventory_source.yml
run_once: true
- name: manage inventory sources
ansible.controller.inventory_source:
controller_host: "https://{{ ansible_host }}"
controller_username: "{{ controller_user }}"
controller_password: "{{ controller_pass }}"
name: "{{ item.name }}"
description: Added via automation
inventory: "{{ item.inventory_name }}"
credential: "{{ item.inventory_credential }}"
overwrite: True
update_on_launch: True
source: "{{ item.source }}"
# source_vars:
# private: false
validate_certs: false
loop: "{{ inv_source }}"