#ansible (2023-06)

ansible

Discussions related to ansible configuration management

2023-06-05

Dan Herrington avatar
Dan Herrington

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.

Hao Wang avatar
Hao Wang

I used Ansible and also fixed some bugs before

Hao Wang avatar
Hao Wang

yeah, Airflow can run Ansible task, most of time I used CICD pipeline

Dan Herrington avatar
Dan Herrington

thanks Hao!

1

2023-06-06

Andrew Miskell avatar
Andrew Miskell

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
Hao Wang avatar
Hao Wang

ansible_connection needs to be associated with a host in inventory file

    keyboard_arrow_up