ioc32 / openhrc

Open Household Router Contraption
Other
13 stars 4 forks source link

Rejig how we handle local variables #7

Closed ioc32 closed 9 years ago

ioc32 commented 9 years ago

Ansible will give the highest priority to those variables provided at the CLI via the -e switch.

This switch accepts YAML or JSON formatted files via '-e @FILE'. This file can be empty.

We can drop an empty local-vars.yml after cloning the repo in bootstrap.sh, which will be ignored via .gitignore.

The key to proper dict overrides is to set hash_behaviour to 'merge' instead of 'replace'. This is more convenient for the user, since individual dictionary keys can be overriden No need to copy the whole dictionary.

saghul commented 9 years ago

Maybe use touch instead? Also, can you update the readme?

ioc32 commented 9 years ago

So, we're now using touch(1) instead of echo(2). README.md updated too!

saghul commented 9 years ago

Can you give a slightly more detailed example? I still don't understand how to override things :-S

ioc32 commented 9 years ago

Something like this:

# ansible-playbook -C --tags test stage2.yml

PLAY [localhost] **************************************************************

GATHERING FACTS ***************************************************************
ok: [localhost]

TASK: [touch /etc/pf-custom.conf] *********************************************
skipping: [localhost]

PLAY RECAP ********************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=0

# vim local-vars.yml
# cat local-vars.yml
firewall:
  enable_custom_rules: true
# ansible-playbook -C --tags test -e @local-vars.yml stage2.yml

PLAY [localhost] **************************************************************

GATHERING FACTS ***************************************************************
ok: [localhost]

TASK: [touch /etc/pf-custom.conf] *********************************************
changed: [localhost]

PLAY RECAP ********************************************************************
localhost                  : ok=2    changed=1    unreachable=0    failed=0
saghul commented 9 years ago

I see! Extra karma if you make it an entry in the FAQ ;-)

ioc32 commented 9 years ago

Let's reword it tomorrow. Mr. Disaronno will help.

saghul commented 9 years ago

LGTM!