Skip to content

Latest commit

 

History

History
47 lines (35 loc) · 1.69 KB

9.Practical Ansible.MD

File metadata and controls

47 lines (35 loc) · 1.69 KB

Practical Ansible

  • There is probably a role for that.
  • You can probably fork and implement your own change in that role easier than you can write your own role.
  • There is probably a module for that.
  • No seriously there is probably a module for THAT.
  • Read the module docs.
  • Don't recreate bash scripts.
  • Command and shell are last resorts.
  • Don't even think about executing a script. Why are you even here?
  • Defaults are nice cause they let other people override them. Be kind to people who reuse your roles.
  • Variables are hard to override so use them when you want to prevent people from shooting themselves in the foot.
  • Variables can be put in a lot of places. Make a decisions and keep it logically consistent.
  • Dynamic inventories are magic but start out with a static one until you get the hang of it.
  • Write the role to solve your problem first then refactor it to make it usable by the open source community.
  • If you have a lot of conditionals (when this do this), remember that tags exists.
  • Modular code is reusable code.
  • Playbooks should not be monolithic.
  • Ansible can run adhoc commands in a bind.
  • Protect your secrets with ansible-vault of credstash!

Tasks on AWS

Useful tips

Host vars are picked up automatically and so are group vars. If you are using open source playbooks effectively you can use role vars, and host vars to accomplish almost all customizations you could hope for.

  • debug module for debugging.
  • also fail and assert.