10.4. cloud-init テンプレートの準備

手順

  1. Satellite Web UI で、ホスト > プロビジョニングテンプレート に移動し、テンプレートの作成 をクリックします。
  2. 名前 フィールドには、テンプレートの名前を入力します。
  3. Editor フィールドで、以下のテンプレートの情報を入力します。

    <%#
    kind: user_data
    name: 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
  4. タイプ タブをクリックして、タイプ リストからユーザーデータのテンプレート を選択します。
  5. 関連付け タブをクリックして、適用可能なオペレーティングシステム リストから、このテンプレートに関連付けるオペレーティングシステムを選択します。
  6. ロケーション タブをクリックして、ロケーション 一覧から、テンプレートを関連付けるロケーションを選択します。
  7. 組織 タブをクリックして、組織 一覧から、テンプレートに関連付ける組織を選択します。
  8. 送信 をクリックします。
  9. ホスト > オペレーティングシステム に移動し、テンプレートに関連付けるオペレーティングシステムを選択します。
  10. テンプレート タブをクリックし、ユーザーデータテンプレート リストから、新規テンプレート名を選択します。
  11. Submit をクリックします。