(env) ~/sibunglon/gist ❯❯❯ ansible-playbook main.yml
PLAY [localhost] *******************************************************************************************************************************************************************************************
TASK [Load Variable 1] *************************************************************************************************************************************************************************************
ok: [localhost] => {
"msg": "example.com/x"
}
TASK [Load variable 2] *************************************************************************************************************************************************************************************
ok: [localhost] => {
"msg": "example.com/x"
}
TASK [Load variable 3] *************************************************************************************************************************************************************************************
ok: [localhost] => {
"msg": "example.com/y"
}
PLAY RECAP *************************************************************************************************************************************************************************************************
localhost : ok=3 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
Created
November 12, 2019 08:04
-
-
Save icarrr/d3ab91c6579c4275697bf36ac995555e to your computer and use it in GitHub Desktop.
ansible-playbook uses variables from different 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
--- | |
config_x: | |
- name: 'Url X' | |
url: 'example.com/x' | |
- name: 'Url Y' | |
url: 'example.com/y' | |
config_y: | |
- name: 'Url X' | |
url: 'example.com/x' | |
- name: 'Url Y' | |
url: 'example.com/y' |
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
--- | |
- hosts: localhost | |
gather_facts: no | |
vars_files: | |
- config.yml | |
tasks: | |
- name: Load Variable 1 | |
debug: | |
msg: "{{ config_x[0].url }}" | |
- name: Load variable 2 | |
debug: | |
msg: "{{ config_y[0].url }}" | |
- name: Load variable 3 | |
debug: | |
msg: "{{ config_y[1].url }}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment