Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

199
Views
How to pull a variable file from S3 in Ansible

My requirement is that I want to dynamically include a variable file in my Ansible script. I can do that by putting following in my ansible task-

- name: Include vars file
  include_vars: vars/dev.yml

- name: Some other task
  cp: copy something

Above works if I keep the dev.yml in my vars directory. Now I actually do not want to put the dev.yml in the directory, I want to pull it from S3 and then use the variable in it. Something like below-

- name: Get dev file
  s3:
    bucket: bucket_name
    object: object_name
    dest: "dest_directory"    ## Here I want the destination to be vars/dev.yml
    mode: get
    aws_access_key: "{{ s3.aws_access_key }}"
    aws_access_key: "{{ s3.aws_secret_key }}"

- name: Include vars file
  include_vars: vars/dev.yml

- name: Some other task that uses vars in dev.yml
  template: render some template using vars in dev.yml and copy to server

The above will actually not work. How do I do this?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Thanks Konstantin Suvorov for help. I just needed to add delegate_to in my task.

- name: Get dev file
  s3:
    bucket: bucket_name
    object: object_name
    dest: vars/dev.yml
    mode: get
    aws_access_key: "{{ s3.aws_access_key }}"
    aws_access_key: "{{ s3.aws_secret_key }}"
  delegate_to: localhost

- name: Include vars file
  include_vars: vars/dev.yml
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!