Last active
March 31, 2020 20:35
-
-
Save gmaurice/b7358742f853f53c79cb8417e5af553a to your computer and use it in GitHub Desktop.
load nginx_vhosts array from files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
** playbook-test.yml | |
- hosts: all | |
gather_facts: no | |
vars: | |
nginx_vhosts: [] | |
tasks: | |
- include_tasks: load-vhosts-conf.yml | |
vars: | |
vhost_file: '{{ item }}' | |
with_filetree: files/vhosts | |
- debug: var=nginx_vhosts | |
** ./load-vhosts-conf.yml | |
--- | |
- name: 'load {{ vhost_file.path }}' | |
include_vars: | |
file: "{{ vhost_file.src }}" | |
name: vhost | |
- set_fact: | |
nginx_vhosts: "{{ nginx_vhosts + [ vhost ] }}" | |
** files/vhosts/a.yml | |
--- | |
name: a | |
** files/vhosts/b.yml | |
--- | |
name: b | |
=========RUN==RUN==RUN==RUN==RUN==RUN==RUN==RUN=================== | |
$ ansible-playbook -i 'localhost,' playbook-test.yml 03/31/20 - 10:30 | |
PLAY [all] ********************************************************************************************************************************************************************************************************************************* | |
TASK [include_tasks] *********************************************************************************************************************************************************************************************************************** | |
included: /Users/germain.maurice/code/home/load-vhosts-conf.yml for localhost | |
included: /Users/germain.maurice/code/home/load-vhosts-conf.yml for localhost | |
TASK [load b.yml] ************************************************************************************************************************************************************************************************************************** | |
ok: [localhost] | |
TASK [set_fact] **************************************************************************************************************************************************************************************************************************** | |
ok: [localhost] | |
TASK [load a.yml] ************************************************************************************************************************************************************************************************************************** | |
ok: [localhost] | |
TASK [set_fact] **************************************************************************************************************************************************************************************************************************** | |
ok: [localhost] | |
TASK [debug] ******************************************************************************************************************************************************************************************************************************* | |
ok: [localhost] => | |
vhosts: | |
- name: b | |
- name: a | |
PLAY RECAP ********************************************************************************************************************************************************************************************************************************* | |
localhost : ok=7 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment