Making environment variables visible in the remote session

Hi,

I’m trying to invoke the route53 command as part of a playbook - this requires access to the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables.

Is there a way to tell ansible to take the exported variables from the local shell and export them to the remote shell when the playbook is run?

Thanks,

Ben

For note, I’ve tried to set the environment explicitly, e.g.

  • name: Update DNS
    action: shell change_record $r53_zone graphite.$domain CNAME $inventory_hostname
    environment:
    AWS_ACCESS_KEY_ID: $ENV(AWS_ACCESS_KEY_ID)

But I’m not sure that I’m using the environment keyword in the correct stanza, as this error indicates:

ERROR: environment is not a legal parameter in an Ansible task or handler

What am I doing wrong here?

Ben Hood wrote:

I'm trying to invoke the route53 command as part of a playbook - this
requires access to the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
environment variables.

Is there a way to tell ansible to take the exported variables from the
local shell and export them to the remote shell when the playbook is
run?

For note, I've tried to set the environment explicitly, e.g.

- name: Update DNS
  action: shell change_record $r53_zone graphite.$domain CNAME
$inventory_hostname
  environment:
AWS_ACCESS_KEY_ID: $ENV(AWS_ACCESS_KEY_ID)

But I'm not sure that I'm using the environment keyword in the correct
stanza, as this error indicates:

ERROR: environment is not a legal parameter in an Ansible task or handler

What am I doing wrong here?

Looks correct. Are you sure you are using a recent version of ansible, i.e.
devel? environment: is new in 1.1.

Daniel

Daniel,