Ghost Transformations II – Merging Data And Filtering The Shadows
A Ghost Operator never touches data blindly.
He merges streams, templates them, and filters JSON and YAML until only what matters remains.
This is your next field manual for advanced data operations in Ansible.
Phase I – Collecting Intel from Multiple Streams
You may have multiple sources of facts: host vars, inventory vars, registered results.
Merging them is like layering ghost signals.
- name: Merge facts from multiple sources set_fact: combined_facts: " {{ hostvars['host1'] | combine(hostvars['host2']) }} "
Each merge hides the operator's intention: one silent variable that holds all intel.
Phase II – Ghost Templates (Dynamic Rendering)
Templates let you shape reality. A Ghost uses them to generate configs, paths, or commands on the fly.
- name: Create a dynamic configuration file template: src: "templates/ghost.conf.j2" dest: "/etc/ghost/ghost.conf"
Inside ghost.conf.j2
, Jinja2 logic bends the data: loops, conditionals, and filters.
Phase III – JSON and YAML Filtering
Not all data is immediately useful. The Ghost extracts only what matters.
- name: Filter JSON from API set_fact: active_users: " {{ api_response.json.users | selectattr('active','equalto',True) | list }} "
- name: Extract paths from YAML inventory set_fact: data_dirs: " {{ yaml_inventory['hosts'] | map(attribute='data_path') | list }} "
Filters, maps, and selects are your spectral knives: precise, silent, lethal.
Phase IV – Combined Ghost Moves
Merge, filter, and template together:
- name: Merge host facts and filter mounted disks set_fact: mounted_data_disks: >- {{ (hostvars['host1'] | combine(hostvars['host2'])).ansible_mounts | selectattr('mount', 'match', '/data/.*') | list }}
The Ghost never acts on raw chaos.
He merges, he filters, he templates - and only then strikes.
Final Word
Advanced Ghost Transformations are about precision.
Merge the streams. Filter the shadows. Template the outcome.
Fear the silence. Fear the switch.
[ TRANSMISSION ENDS ]