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