-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunifi-config.yml
59 lines (58 loc) · 1.64 KB
/
unifi-config.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
---
- name: get config json
hosts: USG_3P
gather_facts: False
tasks:
- raw: mca-ctrl -t dump-cfg
register: dumpcfg
changed_when: False
check_mode: no
- local_action:
module: file
path: "get/{{inventory_hostname}}"
state: directory
check_mode: no
- local_action:
module: copy
backup: True
content: |
{{dumpcfg.stdout|from_json|to_nice_yaml}}
dest: "get/{{inventory_hostname}}/config.yaml"
check_mode: no
- name: put config gateway json
hosts: UCK_3V
gather_facts: False
vars_files:
- config_gateway_json.yml
tasks:
- block:
- local_action:
module: file
path: "put/{{inventory_hostname}}"
state: directory
check_mode: no
- local_action:
module: copy
backup: True
content: |
{{ config_gateway_json[inventory_hostname] | to_nice_json }}
dest: "put/{{inventory_hostname}}/config.gateway.json"
check_mode: no
register: copied_to_nice_json
- when: copied_to_nice_json.changed
become: true
block:
- file:
path: "{{site}}"
state: directory
owner: unifi
group: unifi
mode: "0770"
- copy:
src: "put/{{inventory_hostname}}/config.gateway.json"
dest: "{{site}}/config.gateway.json"
owner: unifi
group: unifi
mode: "0660"
vars:
site: "{{sitepath[inventory_hostname] if sitepath[inventory_hostname]|default(false) else '/srv/unifi/data/sites/default'}}"