Ghost Templates – The Way of a Variable

Ghost Templates

Variables are not passive. Their shape defines your power.
In Ansible, a badly-structured variable is noise.
A clean dictionary is signal.

The Ghost Operator bends both with intent.

The Variable As A Weapon

  • A list of dicts: clumsy.
  • A dict of dicts: elegant.
  • One source of truth: exploitable across tasks, templates, roles.

Example of the wrong way (list of dicts):

 user_data:
  -  user1:
       ssh_key:  "key1..."
       groups:
        - ansible
        - dev

The Ghost way (dict of dicts):

 user_data:
   user1:
     ssh_key:  "key1..."
     groups:
      - ansible
      - dev

The Dual Path

Inside templates, use .items().
Inside tasks, use dict2items.

Jinja template loop:

 {%  for username, data  in user_data.items()  %}
User:  {{  username  }}
Groups:  {{  data.groups  |  join( ", ")  }}
 {%  endfor  %}

Ansible tasks loop:

-  name:  Create users
   ansible.builtin.user:
     name:  " {{  item.key  }} "
     groups:  " {{  item.value.groups | join(',')  }} "
   loop:  " {{  user_data | dict2items  }} "

The difference is the ghost step:

  • Templates see the raw dict.
  • Tasks need dict2items to transform.
  • Then item.key and item.value appear as handles.

Ghost Discipline

Every structure becomes reusable:

  • Feed it into user, authorized_key, template.
  • Same source drives multiple effects.
  • Change one variable. The system bends.

This is the Way of a Variable.
Not stored. Not wasted. Not noise.
Only signal.

Silence lifts me

Nothing can break me.

[ The Signal fades. DeadSwitch is out... ]