amazon web services - How to manage ansible inventory with multiple environments in a scalable and flexible way? -


it seems in ansible world there bit many ways deal inventory , faced hard questions.

we have 4 official target environments: production, staging, testing , local (localhost). groups of hosts inside single inventory.ini located in root.

almost entire infrastructure running on aws, exception developers running local environment on localhost or local vm. still, other non-personal environments on aws.

some staff split different inventories each environment in order avoid accidental execution against @ once. bit concerned increase maintenance costs , make harder work tools ansible tower, semamphore or rundeck. want switch ec2 dynamic inventory makes split less intersting.

here few questions have addresed optimal setup:

  • how deploy specific component towards specific environment?
  • how test playbook without affecting production or staging?
  • what default value should keep "hosts: value" inside our playbooks
  • what should default inventory if use multiple files
  • how can deploy against entire infrastructure (multiple inventories @ same time)

i think it's time dynamic inventory. faced similar issue, had 3 environments deploy , single inventory file. solved storing hosts in database (mongodb in case ) , writing dynamic inventory create host list. selection of environment done adding env variable before calling ansible ( environ=prod ansible-playbook -i inventory ... there bit of logic in inventory avoid deploy production ( uid/gid based ). answer questions:

  • you can use several ways this, use env variable , dynamic inventory, separate inventory files, or use single inventory , name groups (prod|dev|staging)_<hostgroup>
  • this entirely depends on how choose manage inventory
  • there's no default value - hosts: in playbook. select hosts need correct inventory.
  • the default depends on decide, say, don't use production default.. not safest thing, maybe use dev default?
  • just use -i inventory_dir/. can pass directory -i ansible read files , execute -x files.

Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -