PK
Size: a a a
PK
PG
PK
PG
vars:
jsonvar: "json_file.json | from_json }}"
а потом обращайся к jsonvar
{{jsonvar['srv04']['hardware']}}
PK
vars:
jsonvar: "json_file.json | from_json }}"
а потом обращайся к jsonvar
{{jsonvar['srv04']['hardware']}}
PG
PG
vars:
jsonvar: "{{ lookup('file', './tui.json') | from_json }}"
PK
PK
vars:
jsonvar: "{{ lookup('file', './tui.json') | from_json }}"
TG
set_fact:task
network_team_configuration: "{{ [ansible_host]['hardware']['network']['enable_team'] }}"
PK
TG
TG
FT
- name: add certificatesПо задумке, должно в хвост cacert.pem накидать сертификатов из files.
blockinfile:
path: /home/user/cacert.pem
insertafter: EOF
block: "{{ lookup('file', item) }}"
loop: "{{ lookup('fileglob', 'files/*.crt', wantlist=True) }}"
- name: debugНормально проходит по всем.
debug:
msg: "{{ lookup('file', item) }}"
loop: "{{ lookup('fileglob', 'files/*.crt', wantlist=True) }}"
TG
TG
TG
TG
TG
---
- name: Test facts
hosts: localhost
gather_facts: yes
vars_files: cmdb_physical_servers.json
vars:
ansible_connection: local
ansible_host: srv04
tasks:
- name: Debug ansible_host
debug:
var: ansible_host
- name: Debug lookup
debug:
var: lookup('vars', ansible_host)
TG
PLAY [Test facts] ************************
TASK [Gathering Facts] **************************
ok: [localhost]
TASK [Debug ansible_host] ******************
ok: [localhost] =>
ansible_host: srv04
TASK [Debug body] *********************
ok: [localhost] =>
lookup('vars', ansible_host):
hardware:
network:
enable_team: true