1

I managed to connect Foreman and OpenStack, so that I can create VMs in OpenStack using Foreman web interface. I am using cloud-init, or how Foreman calls it, user data provisioning template in order to provision a newly created instance.

For test purpose I am using this cloud-config script:

#cloud-config: users: - name: danil groups: sudo shell: /bin/bash sudo: ['ALL=(ALL) NOPASSWD:ALL'] chpasswd: list: | danil:<hidden> root:<hidden> expire: False runcmd: - apt-get install -y puppet - sed -i -e 's/\[main\]/\[main\]\nserver=foreman.domain.com/' /etc/puppet/puppet.conf - puppet agent --test - puppet agent --enable - puppet agent --test

I am adding a new host and after the VM is spun up, I can see it as a host with the name new-host.domain.com with model name OST2, the name that I am using for OpenStack compute resource in Foreman. Inside that host I can do some basic tasks, such as Power off the VM, delete it and so one.

Cloud config script does its job, i.e. it installs puppet and makes this VM manageable by puppet via Foreman smart proxy. As soon as puppet finishes host initialization, I see a duplicate host with the name "new-host". In case of that duplicate host, it has model name "OpenStack Nova". It is manageable by puppet, but none of the OpenStack tasks that are available to new-host.domain.com are there.

In other words I have two records for the same host. One record can be used to manage a VM and another record to manage the operating system configuration wit help of puppet.

Is there any way to merge those two records, in order to avoid these duplicate records?

The YAML that corresponds to the newly created VM new-host.domain.com is:

classes: {} parameters: puppetmaster: puppet.domain.com hostgroup: Provision from puppet.domain.com root_pw: <hidden> puppet_ca: puppet.domain.com foreman_env: production owner_name: Admin User owner_email: root@domain.com foreman_subnets: [] foreman_interfaces: - mac: ip: 172.21.82.102 type: Interface name: new-host.vccap.de attrs: {} virtual: false link: true identifier: '' managed: true primary: true provision: true subnet: environment: production

Thanks for you replies!

Best regards,

Danil

  • What's "facter fqdn" output on the new VM? It sounds like Puppet's certname isn't getting the domain, so it's identifying differently. You could even try adding "certname = <%= @host.name %>" to puppet.conf in the user data template. – Dominic Cleal Jan 08 '16 at 15:32
  • The certificate contained 'CN=danil'. So it explains the wrong mapping now. Is it possible to set FQDN during instance creation that always matches name of the host in Foreman + domain name? Now the option that I see is to edit /etc/hosts in cloud-init script. But is doesn't seem to be very flexible option. I also see that during new host creation there is domain name set, but after the instance is created, there is no FQDN in /etc/hosts – Danil Zhigalin Jan 11 '16 at 15:35
  • Taking into account the attached YAML in my edited post, should I expect that /etc/hosts will contain '172.21.82.102 new-host.domain.com' or it needs to be done via cloud-init? – Danil Zhigalin Jan 11 '16 at 15:48

1 Answers1

0

Thanks m0dlx for providing an operational answer to my question. I've also found useful Provisioning template, that was available in Foreman installation that also solves this problem. Template is called "kickstart user data" and is made for Fedora and CentOS, but with small changes also fits ubuntu.