Hi, I'm an ansible noob, and I'm following this tutorial to use the rax
module to spin up and configure rackspace servers
http://nicholaskuechler.com/2015/01/09/build-rackspace-cloud-servers-ansible-virtualenv/#comment-550108
It's great but it's not dynamic, as you can seemingly only add one server
to the dynamic inventory. So I altered it to add servers through with_items
like so
tasks:
- name: Rackspace cloud server build request
local_action:
module: rax
credentials: "{{ credentials }}"
name: "{{ item }}"
flavor: "{{ flavor }}"
image: "{{ image }}"
region: "{{ region }}"
files: "{{ files }}"
wait: yes
state: present
networks:
- private
- public
with_items:
- server-app-01
- server-app-02
register: rax
But the problem is that I can't access these variables to add them to the
dynamic inventory. I tried doing what the documentation said and taking
into account the new 'results' key in the object, but nothing I do results
in it correctly targeting the object value I want. This, to me, is the most
logical attempt I have made for the results array, (which you can a
stripped out version of here <http://pastebin.com/NRvM7anS>, these servers
no longer exist)
- name: Add each cloud server to host group
local_action:
module: add_host
hostname: "{{ item.instances.name }}"
ansible_ssh_host: "{{ item.instances.rax_accessipv4 }}"
ansible_ssh_user: root
groupname: deploy
with_items: rax.results
This one results in
One or more undefined variables: 'list object' has no attribute
'rax_accessipv4'
I have tried using rax.results.instances and then using item.name etc, but
this results in
One or more undefined variables: 'unicode object' has no attribute
'rax_accessipv4'
I've tried too many to list here, for a very long time, but I've obviously
got confused with how this is supposed to work, can I get some help please?
--
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/881845c0-31d4-4d70-8923-58e31fe2d0fd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.