#ansible - June 2023

ansibleArchived
2 messages

Discussions related to ansible configuration management

Dan Herrington
Dan Herringtonover 3 years ago
Hey all, I'm wondering if anybody here uses ansible for some system ops tasks like backup?
I'm migrating those scripts off of cron to airflow, but then thought they could also be executed from ansible.
I'd still use airflow to schedule the ansible playbook, but then create a group of servers on that the backup playbook gets applied to.
Andrew Miskell
Andrew Miskellover 3 years ago
Is it possible to configure a set of host variables for all hosts in an inventory?

I'm using aws_ec2 plugin and want to set the following variables for all hosts so I don't have to repeat them over and over in each playbook since we're using aws_ssm connection plugins to connect to all our ec2 hosts.

ansible_connection: aws_ssm
ansible_aws_ssm_region: us-east-1
ansible_aws_ssm_bucket_name: <bucket name>
ansible_remote_tmp: /tmp/.ansible
ansible_python_interpreter: python3

I checked the documentation and below seems right based on the docs, but it's not working ansible is still trying to connect via ssh.

all:
  vars:
    ansible_connection: aws_ssm
    ansible_aws_ssm_region: us-east-1
    ansible_aws_ssm_bucket_name: <bucket-name>
    ansible_remote_tmp: /tmp/.ansible
    ansible_python_interpreter: python3

plugin: amazon.aws.aws_ec2
regions:
  - us-east-1

keyed_groups:
  - key: tags.Application
    separator: ''
  - key: tags.Tenant
    separator: ''

hostnames:
  - name: 'tag:Name'
compose:
  ansible_host: instance_id