# autoscaling\_group + add\_host == not possible?

**URL:** <https://forum.ansible.com/t/autoscaling-group-add-host-not-possible/15763>\
**Category:** Ansible Project\
**Created:** [July 24, 2014, 1:43pm UTC](https://forum.ansible.com/t/autoscaling-group-add-host-not-possible/15763 "2014-07-24T13:43:32Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Guy\_Matz1](https://avatars.discourse-cdn.com/v4/letter/g/b5e925/32.png) [@Guy\_Matz1](https://forum.ansible.com/u/Guy_Matz1)\
**Post date:** [July 24, 2014, 1:43pm UTC](https://forum.ansible.com/t/autoscaling-group-add-host-not-possible/15763/1 "2014-07-24T13:43:32Z")

</div>

Hi! Is there any way to provision hosts built by a rax\_scaling\_group? Is it possible to re-read dynamic inventory midway through the run - after the servers have been built - and have them ansibled? Or is the only option to have them pull after they build?

Thanks a lot!  
Guy

---

<div class="post-metadata">

**Author:** ![Michael\_Peters](https://avatars.discourse-cdn.com/v4/letter/m/c2a13f/32.png) [@Michael\_Peters](https://forum.ansible.com/u/Michael_Peters)\
**Post date:** [July 24, 2014, 2:08pm UTC](https://forum.ansible.com/t/autoscaling-group-add-host-not-possible/15763/2 "2014-07-24T14:08:57Z")

</div>

If I understand correctly, this is what add\_hosts is for. After you've  
dynamically created a host you can add it to a group and then in a  
subsequent play include a role that would configure that group.

Is that what you're looking for?

---

<div class="post-metadata">

**Author:** ![Guy\_Matz1](https://avatars.discourse-cdn.com/v4/letter/g/b5e925/32.png) [@Guy\_Matz1](https://forum.ansible.com/u/Guy_Matz1)\
**Post date:** [July 24, 2014, 2:51pm UTC](https://forum.ansible.com/t/autoscaling-group-add-host-not-possible/15763/3 "2014-07-24T14:51:22Z")

</div>

Right, but with an auto-scaling group I don’t know of a way to get the new hostnames of the servers the AS group creates . . . the new host are not returned in the output from the call to create the autoscaling group

Thanks,  
Guy

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [July 24, 2014, 3:26pm UTC](https://forum.ansible.com/t/autoscaling-group-add-host-not-possible/15763/4 "2014-07-24T15:26:35Z")

</div>

Tower provisioning callbacks embedded into the image are a GREAT solution for this.

[http://www.ansible.com/tower](http://www.ansible.com/tower)

Alternatively schedule a run to configure and apply policy periodically, only adding machines into the LB once configured.

Alternatively, ansible-pull

The provisioning callbacks are the cleanest option and allow ephmeral systems to request configuration as they come online, while still operating in push mode and getting full history/status/logging of activity during that configuration (as with ansible-pull this info can be lost).

---

<div class="post-metadata">

**Author:** ![James\_Martin1](https://avatars.discourse-cdn.com/v4/letter/j/0ea827/32.png) [@James\_Martin1](https://forum.ansible.com/u/James_Martin1)\
**Post date:** [July 24, 2014, 5:53pm UTC](https://forum.ansible.com/t/autoscaling-group-add-host-not-possible/15763/5 "2014-07-24T17:53:30Z")

</div>

Instead of baking the Tower callback script into the AMI, it also can be baked into the ASG’s Launch Config User Data. That may be a bitter easier to manage.

- James

---

<div class="post-metadata">

**Author:** ![Guy\_Matz1](https://avatars.discourse-cdn.com/v4/letter/g/b5e925/32.png) [@Guy\_Matz1](https://forum.ansible.com/u/Guy_Matz1)\
**Post date:** [July 24, 2014, 6:18pm UTC](https://forum.ansible.com/t/autoscaling-group-add-host-not-possible/15763/6 "2014-07-24T18:18:34Z")

</div>

☹ I’m on Rackspace ☹

😉

---

<div class="post-metadata">

**Author:** ![Paul\_Durivage](https://avatars.discourse-cdn.com/v4/letter/p/94ad74/32.png) [@Paul\_Durivage](https://forum.ansible.com/u/Paul_Durivage)\
**Post date:** [July 24, 2014, 8:37pm UTC](https://forum.ansible.com/t/autoscaling-group-add-host-not-possible/15763/7 "2014-07-24T20:37:45Z")

</div>

Hi Guy!

I’m not an expert on this module because it’s my coworker who wrote it and not me, so I’ll try to give you as much good advice as I can. So I think the issue here is that the autoscale groups don’t return data about the servers they may create or delete. Correct me if I’m wrong in my understanding.

So, this isn’t an issue with the module per se, it’s more of an issue with the way that ASGs operate – you create ASGs and they in turn create servers, or delete them, work on load balancers, etc.

Ansible won’t know about these servers until you run the dynamic inventory script again.

There are three ways to handle this, I think:

1. ansible-pull
2. tower + webhooks
3. bake-in ansible-pull into the image so that it ansible-pulls on boot

The first two methods will take advantage of cloud-init, essentially. So,

1. For ansible-pull you’ll need to cloud-init install ansible-pull ont he machine as it comes online, and when it does, it pulls down a git repo, and “Ansibles” itself.
2. But for Tower & Webhooks, when a server comes online, have it use a cloud-init webhook to call back to a Tower server, which would then kick of a playbook of some kind
3. Baking in ansible-pull is really simple but requires work ahead of deployment; can’t be done afterwards via ansible in they way you desire (you could write a playbook to do this before hand, though!)

When you’re working with Autoscale, cloud-init is your new BFF. It’ll handle the stuff you’re looking to do.

There’s more documentation about cloud-init around. Here’s a started article:  
[https://developer.rackspace.com/blog/using-cloud-init-with-rackspace-cloud/](https://developer.rackspace.com/blog/using-cloud-init-with-rackspace-cloud/)

And this is a repo made by a Racker specifically covering getting Autoscale working with cloud-init.  
[https://github.com/devx/autoscale\_cloudinit](https://github.com/devx/autoscale_cloudinit)

Essentially, when you set up your autoscale configuration, you’ll need to pass some custom data, base64 encoded a la the webdocs:  
[http://docs.rackspace.com/cas/api/v1.0/autoscale-devguide/content/Manage\_Launch\_Configuration.html](http://docs.rackspace.com/cas/api/v1.0/autoscale-devguide/content/Manage_Launch_Configuration.html)  
[http://docs.rackspace.com/servers/api/v2/cs-devguide/content/config\_drive\_ext.html](http://docs.rackspace.com/servers/api/v2/cs-devguide/content/config_drive_ext.html)

**Please note that the current implementation of the rax\_autoscale\_group does not allow you to work with cloud-init, but I have an idea of how I might go about adding such functionality. Apologies for the inconvenience.**
