Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

187
Visualizações
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?

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

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
about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda