This:
http://stackoverflow.com/questions/31708736/passing-variables-between-nested-playbooks
suggests that if I change the "hosts" (which I do), then the set_fact vars
are NOT persisted between plays. Correct?
J
On Friday, November 20, 2015 at 11:25:55 AM UTC-6, Slim Slam wrote:
>
> Ansible v1.9.4
>
> I have a playbook that I launch with:
>
> $ ansible-playbook build.yml
>
> build.yml includes set_os.yml (just a set of tasks) that launches some ec2
> instances. build.yml looks like this.
>
> - name: Build stuff
> hosts: localhost
> sudo: False
> gather_facts: False
> tasks:
> - include: set_os.yml
> - include: build_soft.yml
>
> In the file set_os.yml, I set the remote user like this:
>
> - set_fact:
> ruser: ubuntu
>
> When I include build_soft.yml above (a new play), I want to use that
> remote user to login and configure the new EC2 instance like so:
>
> ---
> - name: Configure the EC2 instance
> hosts: ec2hosts
> gather_facts: true
> remote_user: "{{ ruser }}"
> tasks:
> - do something......
>
> Since "set_fact" definitions are supposed to work between plays (?), I
> assume it will still be defined, but I always get this error when
> build_soft.yml executes:
>
> GATHERING FACTS
> ***************************************************************
> <33.34.115.33> ESTABLISH CONNECTION FOR USER: {{ ruser }}
> <33.34.115.33> REMOTE_MODULE setup
> <33.34.115.33> EXEC ssh -C -tt -vvv -F ../config/sshconfig -o
> ControlPersist=15m -o ControlPath=
> "/someuser/.ansible/cp/ansible-ssh-%h-%p-%r" -o StrictHostKeyChecking=no -o
> IdentityFile="mykey.pem" -o KbdInteractiveAuthentication=no -o
> PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey
> -o PasswordAuthentication=no -o User={{ ruser }} -o ConnectTimeout=10
> 33.34.115.33 /bin/sh -c 'mkdir -p
> $HOME/.ansible/tmp/ansible-tmp-1448039631.2-14623163715246 && chmod a+rx
> $HOME/.ansible/tmp/ansible-tmp-1448039631.2-14623163715246 && echo
> $HOME/.ansible/tmp/ansible-tmp-1448039631.2-14623163715246'
> fatal: [33.34.115.33] => SSH Error: command-line line 0: garbage at end
> of line; "ruser".
>
> Any ideas?
>
> -J
>
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/baf0c1b0-b5e9-4965-bd58-6a56e6868962%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.