This article was originally published on the Red Hat Customer Portal. The information may no longer be current.
As part of the upcoming 6.2.12 release, we are adding additional support for cloud-init provisioning using the Red Hat Enterprise Virtualization (RHEV/RHV) provider.
The Cloud-init tool allows to configure the provisioned virtual machine via a configuration, that is passed to the VM though the virtualization platform (RHV in this case).
The advantage of this approach is not requiring any special configuration on the network (such as managed DHCP and TFTP) in order to finish the installation of the virtual machine, neither it requires for the Satellite to actively connect to the provisioned machine via SSH to run the finish script.
It is also faster than the network-based provisioning, as we are using an image with pre-installed operating system.
VM Template Preparation
There are two ways we can get a cloud-init ready image to our RHV instance.
The first one is using the KVM base image on from our portal and import it to the RHV. The image should already have cloud-init installed.
The second option is building the template from scratch. For that, will use a standard server installation of RHEL 7 as a base.
We install cloud-init from the rhel-7-server-rpms repository:
yum install -y cloud-init
Next, we will do some basic cloud-init configuration. By default, cloud-init tries to load the configuration from external sources. While this is being used with some cloud providers, in case of RHEV, the data are being passed to the VM via a mounted drive and the additional data sources make some unnecessary delays. Therefore, we will set the following in /etc/cloud/cloud.cfg:
datasource_list: ["NoCloud", "ConfigDrive"]
This should be just enough configuration we need to do. As the final step, I recommend following steps to make a clean VM for use as a template or clone to make sure the newly reacted VMs will start from scratch.
Preparing Satellite for the cloud-init provisioning
We assume that the Satellite was already configured to provision hosts via RHV, either using network based provisioning or finish scripts via SSH.
First of all, we need to add the newly create image to the Satellite.
In Satellite, go to Infrastructure -> Compute Resources -> Your RHV resource, in the Images tab click New Image button. Fill in the necessary details. Make sure to check the "User Data" checkbox: this way the Satellite will know to use the cloud-init template, when provisioning the VM.
Next, we will create a provisioning template that will generate the cloud-init configuration. Currently, the list of configuration options for the cloud-init is limited. However, even with the subset of commands, it's possible to do just enough for finishing the configuration. We will go to Hosts -> Provisioning Templates and create a new template:
<%#
kind: user_data
name: My Satellite RHV Cloud-init
-%>
#cloud-config
hostname: <%= @host.shortname %>
<%# Allow user to specify additional SSH key as host paramter -%>
<% if @host.params['sshkey'].present? || @host.params['remote_execution_ssh_keys'].present? -%>
ssh_authorized_keys:
<% if @host.params['sshkey'].present? -%>
- <%= @host.params['sshkey'] %>
<% end -%>
<% if @host.params['remote_execution_ssh_keys'].present? -%>
<% @host.params['remote_execution_ssh_keys'].each do |key| -%>
- <%= key %>
<% end -%>
<% end -%>
<% end -%>
runcmd:
- |
#!/bin/bash
<%= indent 4 do
snippet 'subscription_manager_registration'
end %>
<% if @host.info['parameters']['realm'] && @host.realm && @host.realm.realm_type == 'Red Hat Identity Management' -%>
<%= indent 4 do
snippet 'idm_register'
end %>
<% end -%>
<% unless @host.operatingsystem.atomic? -%>
# update all the base packages from the updates repository
yum -t -y -e 0 update
<% end -%>
<%
# safemode renderer does not support unary negation
non_atomic = @host.operatingsystem.atomic? ? false : true
pm_set = @host.puppetmaster.empty? ? false : true
puppet_enabled = non_atomic && (pm_set || @host.params['force-puppet'])
%>
<% if puppet_enabled %>
yum install -y puppet
cat > /etc/puppet/puppet.conf << EOF
<%= indent 4 do
snippet 'puppet.conf'
end %>
EOF
# Setup puppet to run on system reboot
/sbin/chkconfig --level 345 puppet on
/usr/bin/puppet agent --config /etc/puppet/puppet.conf --onetime --tags no_such_tag <%= @host.puppetmaster.blank? ? '' : "--server #{@host.puppetmaster}" %> --no-daemonize
/sbin/service puppet start
<% end -%>
phone_home:
url: <%= foreman_url('built') %>
post: []
tries: 10pp
This is an equivalent of "Satellite Kickstart Default" template written using the cloud-init modules. In the Type tab, we will select User data template and in Association tab, we will add this template for the operating system we want to assign it to. Don't forget to also go to the details of the operating system (Hosts -> Operating Systems -> Your Selected OS) and select the newly created template as User data template.
This should be enough configuration for us to start with provisioning the hosts using the cloud-init.
Next steps
As mentioned, there is still some work to be done to make availability of wider range for the cloud-init modules and we are working in upstream projects to make it happened. However, I hope that even this small addition will make your life and provisioning easier.
저자 소개
유사한 검색 결과
More than meets the eye: Behind the scenes of Red Hat Enterprise Linux 10 (Part 4)
Accelerating NetOps transformation with Ansible Automation Platform
Technically Speaking | Platform engineering for AI agents
Technically Speaking | Driving healthcare discoveries with AI
채널별 검색
오토메이션
기술, 팀, 인프라를 위한 IT 자동화 최신 동향
인공지능
고객이 어디서나 AI 워크로드를 실행할 수 있도록 지원하는 플랫폼 업데이트
오픈 하이브리드 클라우드
하이브리드 클라우드로 더욱 유연한 미래를 구축하는 방법을 알아보세요
보안
환경과 기술 전반에 걸쳐 리스크를 감소하는 방법에 대한 최신 정보
엣지 컴퓨팅
엣지에서의 운영을 단순화하는 플랫폼 업데이트
인프라
세계적으로 인정받은 기업용 Linux 플랫폼에 대한 최신 정보
애플리케이션
복잡한 애플리케이션에 대한 솔루션 더 보기
가상화
온프레미스와 클라우드 환경에서 워크로드를 유연하게 운영하기 위한 엔터프라이즈 가상화의 미래