Orchestration between OS Provisioning and Configuration Management (Barrier Behavior between Cobbler and Ansible)

I configure Cobblerd in a certain way to install OS onto my bare-metal machines. Say I configured 5 systems (therefore intend to install 5 machines).

Then I would like to configure the following inventory (suppose Cobbler configuration has taken care of the static IP address setup for the bare metal machine)

(/etc/ansible/hosts)
[webservers]
10.20.2.11
10.20.2.12
[dbservers]
10.20.2.13
10.20.2.14
10.20.2.15

I would like wait to run my playbook until the OS have been actually provisioned. Otherwise, my playbook will fail because the nodes won’t be read for ssh.

My question is whether there is a way to make a barrier between Cobbler installation finished and the Ansible cookbook start to launch. Is there a notification mechanism so that I can wait all 5 machines’ OS are ready?

Thanks,
Sean

Sean <sean.bigdatafun@gmail.com> napisał:

My question is whether there is a way to make a barrier between Cobbler
installation finished and the Ansible cookbook start to launch. Is
there a
notification mechanism so that I can wait all 5 machines' OS are ready?

I don't know about cobbler, but you can wait for the machines with wait_for module (http://docs.ansible.com/wait_for_module.html). Something like this at the beginning of your playbook will wait until all the hosts have port 22 open (but no longer than 900 seconds):

- hosts: all
  gather_facts: no # makes sure Ansible won't attempt connection too soon
  tasks:
    - local_action: wait_for host={{inventory_hostname}} port=22 timeout=900

A few options that don’t involve ansible calling Cobbler:

(A) admit defeat and run it in two steps - base OS install, trigger ansible

(B) trigger ansible-pull at the end of the cobbler run in kickstart %post.

(C) trigger ansible at the end of the cobbler run in kickstart %post using provisioning callbacks in Tower. This doesn’t work 100% smoothly though because Tower doesn’t have a “automatically sync with cobbler” integration like it does with AWS and Rackspace. This will likely happen for arbitrary inventory scripts later.

Though having ansible call the cobbler edit command with --force is not a bad idea. It could set up DHCP/DNS with a simple edit command and then wait for connectivity.

You may also want to look into the “do/until” loop constructs if you’d like to also wait for another service to come online.

In the past, I’ve seen people try to synchronize a config tool list of info with cobbler, and that usually gets complicated. But if it’s just going to wrap “cobbler ___ edit” + a few commands, wait for SSH, and then do the rest that’s ok.

Ansible pull would be pretty simple though, provided you were ok with having some of the bootstrap stuff in an accessible git repo.

Alternatively you could also package the playbook in a tarball, etc, extract it in post, etc. ansible-pull is really just a proof of concept that is completely usable in the real world in many cases :slight_smile:

Hi,

I am also looking for a similar solution. I have cobbler server setup that takes care of OS + Network Config. My cobbler server is now also my ansible control machine. So I have Cobbler + Ansible on the same server.

From the 3 options mentioned by you, A is not a choice for me and C seems to be second choice for me. First choice would be (B) trigger ansible-pull at the end of the cobbler run in kickstart %post. Does this require ansible installation on the newly built node ? If not, can you please describe how should I achieve this ? If it requires ansible installation on the newly built instance, I have to work out something else.

Thanks in advance,
Hrishikesh