Vault Variables

In the playbook add vars: followed by the variables to be defined. These can be ansible-vault encrypted strings.

---
- name: a sample playbook
  hosts: localhost
  become: yes
  remote_user: stevc

  vars:
    sample_variable: !vault |
           $ANSIBLE_VAULT;1.1;AES256
           STUFF STUFF STUFF

  tasks:
    - do stuff

Playbook specific vaults

Use vars_files to specify a vault for sensitive variables.

---
- hosts: localhost
  user: ansible

  vars_files:
  - vars/vault.yml

  vars:
    variable1: test

Special variables

ansible special variables <https://docs.ansible.com/ansible/latest/reference_appendices/special_variables.html>

Special nod to inventory_hostname and inventory_hostname_short