On Monday, September 11, 2017 at 3:06:01 PM UTC-5, Ivan Necas wrote: > > Hi, it seems like you're user-data template is not rendering a proper > YAML that `YAML.load()` would parse > as a Hash. Could you share the rendered user-data template with us or > even better, run `irb` and try: > > The one in question is the Kickstart user_data default provided in Foreman 1.15.1. It doesn't look like yaml at all to me.
<%# kind: user_data name: Kickstart default user data oses: - CentOS - Fedora -%> <% rhel_compatible = @host.operatingsystem.family == 'Redhat' && @host.operatingsystem.name != 'Fedora' # safemode renderer does not support unary negation pm_set = @host.puppetmaster.empty? ? false : true proxy_uri = @host.params['http-proxy'] ? "http://#{@host.params['http-proxy']}:#{@host.params['http-proxy-port']}" : nil puppet_enabled = pm_set || @host.param_true?('force-puppet') salt_enabled = @host.params['salt_master'] ? true : false chef_enabled = @host.respond_to?(:chef_proxy) && @host.chef_proxy -%> #!/bin/bash <%# Cloud instances frequently have incorrect hosts data %> <%= snippet 'fix_hosts' %> <% if @host.provision_method == 'image' && !root_pass.empty? -%> # Install the root password echo 'root:<%= root_pass -%>' | /usr/sbin/chpasswd -e <% end -%> <% if proxy_uri -%> # Yum proxy echo 'proxy = <%= proxy_uri %>' >> /etc/yum.conf <% end -%> #update local time echo "updating system time" yum -y install ntpdate /usr/sbin/ntpdate -sub <%= @host.params['ntp-server'] || '0.fedora.pool.ntp.org' %> /usr/sbin/hwclock --systohc <% if rhel_compatible && [email protected]_false?('enable-epel') -%> <%= snippet 'epel' -%> <% end -%> <% if @host.info['parameters']['realm'] && @host.realm && @host.realm.realm_type == 'FreeIPA' -%> <%= snippet 'freeipa_register' %> <% end -%> <% unless @host.param_false?('package_upgrade') -%> # update all the base packages from the updates repository if [ -f /usr/bin/dnf ]; then dnf -y update else yum -t -y update fi <% end -%> <%= snippet('remote_execution_ssh_keys') %> <% if chef_enabled %> <%= snippet 'chef_client' %> <% end -%> <% if puppet_enabled %> <% if @host.param_true?('enable-puppetlabs-pc1-repo') || @host.param_true?('enable-puppetlabs-repo') -%> <%= snippet 'puppetlabs_repo' %> <% end -%> <%= snippet 'puppet_setup' %> <% end -%> <% if salt_enabled %> <%= snippet 'saltstack_setup' %> <% end -%> # UserData still needs to mark the build as finished /usr/bin/curl -o /dev/null -k '<%= foreman_url('built') %>' The one that DOES have yaml look to it is the one that says "this is not a user_data template". That is the one provided with Foreman 1.15.1 as "UserData default" <%# kind: user_data name: UserData default oses: - CentOS - Fedora - Debian - Ubuntu -%> <%# This template accepts the following parameters: - ssh_pwauth: boolean (default=true unless ssh_authorized_keys) - ssh_authorized_keys: string w newline seperated keys (default="") - package_upgrade: boolean (default=false) - reboot: boolean (default=false) -%> <% ssh_pwauth = @host.params['ssh_pwauth'] ? @host.param_true?('ssh_pwauth') : [email protected]['ssh_authorized_keys'] rhel_compatible = @host.operatingsystem.family == 'Redhat' && @host.operatingsystem.name != 'Fedora' # safemode renderer does not support unary negation pm_set = @host.puppetmaster.empty? ? false : true puppet_enabled = pm_set || @host.param_true?('force-puppet') salt_enabled = @host.params['salt_master'] ? true : false chef_enabled = @host.respond_to?(:chef_proxy) && @host.chef_proxy -%> #cloud-config hostname: <%= @host.shortname %> fqdn: <%= @host %> manage_etc_hosts: true <% if ssh_pwauth -%> <%# Don't enable this in production. It is very insecure! Use ssh_authorized_keys instead... http://cloudinit.readthedocs.io/en/latest/topics/examples.html#including-users-and-groups -%> ssh_pwauth: true groups: - admin users: - default - name: admin primary-group: admin groups: users shell: /bin/bash sudo: ['ALL=(ALL) ALL'] lock-passwd: false passwd: <%= @host.root_pass %> <% end -%> <% if @host.params['ssh_authorized_keys'] -%> ssh_authorized_keys: <% @host.params['ssh_authorized_keys'].split("\n").each do |ssh_key| -%> - <%= ssh_key %> <% end -%> <% end -%> <% if @host.param_true?('package_upgrade') -%> package_upgrade: true <% end -%> runcmd: <% if rhel_compatible -%> - | <%= indent(2) { snippet('epel') } %> <% end -%> - | <%= indent(2) { snippet('remote_execution_ssh_keys') } %> <% if chef_enabled -%> - | <%= indent(2) { snippet('chef_client') } %> <% end -%> <% if puppet_enabled -%> - | <%= indent(2) { snippet('puppetlabs_repo') } %> - | <%= indent(2) { snippet('puppet_setup') } %> <% end -%> <% if salt_enabled -%> - | <%= indent(2) { snippet('saltstack_setup') } %> <% end -%> <%# Contact Foreman to confirm instance is built -%> phone_home: url: <%= foreman_url('built') %> post: [] tries: 10 <% if @host.param_true?('reboot') -%> power_state: mode: reboot timeout: 30 condition: true <% end -%> Does that help? I've only just started working with image builds so still trying to pickup what goes where properly so it could be entirely me not flipping the right switches. -- You received this message because you are subscribed to the Google Groups "Foreman users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/foreman-users. For more options, visit https://groups.google.com/d/optout.
