Skip to content

Instantly share code, notes, and snippets.

@mohclips
Created November 26, 2019 11:21
Show Gist options
  • Save mohclips/9eefe2172a79245045b57a882927fd46 to your computer and use it in GitHub Desktop.
Save mohclips/9eefe2172a79245045b57a882927fd46 to your computer and use it in GitHub Desktop.
Read a remote yaml file
- hosts: search_master, search_data
serial: 1 # run one at a time
gather_facts: false
become: yes
vars:
# cannot be done as lookup are only on the Ansible controller
#config: "{{ lookup('file','/etc/elasticsearch/elasticsearch.yml') | from_yaml }}"
tasks:
- command: >
cat /etc/elasticsearch/elasticsearch.yml
register:
raw_config
- name: output
vars:
config: "{{ raw_config.stdout | from_yaml }}"
debug:
var: config['cluster.name']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment