I'm running into some trouble with Rackspace provisioning. I am attempting to provision a new host and then add it to the in-memory host to continue with the rest of the plays.
The provisioning looks like this:
- name: "Ensure {{ num_tomcat_servers }} Tomcat servers exist"
local_action:
module: rax
api_key: <excluded>
username: <excluded>
region: <excluded>
service: cloudservers
state: active
wait: yes
wait_timeout: 600
flavor: <excluded>
image: <excluded>
name: 'identifier-tomcat-{{ item }}'
meta:
group: tomcat
with_sequence: count={{ num_tomcat_servers }}
register: tomcat_hosts
notify:
- Register tomcat instances
- Group tomcat instances
Then, I have these handlers invoked:
handlers:
- name: Register tomcat instances
local_action: add_host name={{ item.accessIPv4 }} groups={{
item.name }}
with_items: tomcat_hosts.instances
- name: Group tomcat instances
local_action: add_host name={{ item.accessIPv4 }} groups=tomcat
with_items: tomcat_hosts.instances
The idea here is that I will add all of the instances to their respective name group (identifer-tomcat-1, identifier-tomcat-2, etc) as well as a more generic group called 'tomcat'. This is the only way that I could figure out how to do that (using 2 handlers)
The issue that I get is in the handler. It seems to bomb out on the add_host line:
_____________________________________
< NOTIFIED: Register tomcat instances >
-------------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
fatal: [127.0.0.1] => One or more undefined variables: 'str object' has no attribute 'accessIPv4'
I can't seem to figure out what I'm doing wrong. The Rackspace plugin returns the following after it succeeds:
module.exit_json(changed=changed, instances=instances)
Where each item in 'instances' is this:
'accessIPv4': server.accessIPv4,
'status': server.status}
Anybody have any juice on this? It almost seems like the {{ item }} reference in the handler is attempting to use the {{ item }} from the sequence above. I'll keep debugging to see if I can obtain any additional information.
--
Phillip Verheyden