I won't parse the code for you, but it is easy to create a ERB parser,
fake some variables and methods there and perform a test. We do this
with some template kinds, maybe you want to write similar test for
cloud init and then run it on your template?

https://github.com/theforeman/community-templates

Check snippets, the bug can be hidden in snippets!

LZ

On Wed, Dec 6, 2017 at 3:36 PM, Christian Setzer
<[email protected]> wrote:
> i've now created scripts for all 5 types that are assigned to an OS.
> the only line in is #foo
>
> the error im getting is the same.
>
>
> Unable to save
> Render user data template for cesar-steere.1000.local task failed with the
> following error: ERF22-1307 [Foreman::Renderer::SyntaxError]: Syntax error
> occurred while parsing the template Unnamed, make sure you have all ERB tags
> properly closed and the Ruby syntax is valid. The Ruby error: (string):86 ::
> parse error on value "<" (tLT)
>
> Am Mittwoch, 6. Dezember 2017 13:40:43 UTC+1 schrieb Christian Setzer:
>>
>> http://debugs.theforeman.org/foreman-debug-asEiW.tar.xz
>>
>> problem i am having is that i use a user data script with 75 lines and the
>> error i am getting is
>>
>> Unable to save
>> Render user data template for cesar-steere.1000.local task failed with the
>> following error: ERF22-1307 [Foreman::Renderer::SyntaxError]: Syntax error
>> occurred while parsing the template Unnamed, make sure you have all ERB tags
>> properly closed and the Ruby syntax is valid. The Ruby error: (string):86 ::
>> parse error on value "<" (tLT)
>>
>> while creating a new host.
>>
>> i hope that 86 means the line number?!
>>
>> the script is pretty much standart and the erb ruby syntax check is ok and
>> preview check in foreman too.
>>
>> ----
>>
>> <%#
>> kind: user_data
>> name: Katello Kickstart default user data
>> oses:
>> - CentOS 6
>> - CentOS 7
>> - Fedora 19
>> - Fedora 20
>> - Fedora 21
>> - Fedora 22
>> - Fedora 23
>> -%>
>> #cloud-config
>> hostname: <%= @host.shortname %>
>> fqdn: <%= @host %>
>> manage_etc_hosts: 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 %>
>>
>> <% 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 -%>
>> write_files:
>> - path: /tmp/foreman-userdata.sh
>>   permissions: '0755'
>>   content: |
>>     #!/bin/bash
>> <%= snippet 'subscription_manager_registration'-%>
>> <% if @host.info['parameters']['realm'] && @host.realm &&
>> @host.realm.realm_type == 'FreeIPA' -%>
>> <%= snippet 'freeipa_register'-%>
>> <% 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'])
>>   salt_enabled = non_atomic && (@host.params['salt_master'] ? true :
>> false)
>>   chef_enabled = @host.respond_to?(:chef_proxy) && @host.chef_proxy
>> %>
>>
>> <% if puppet_enabled %>
>> <%= snippet 'puppet_setup' %>
>> <% end -%>
>>
>>
>> phone_home:
>>  url: <%= foreman_url('built') %>
>>  post: []
>>  tries: 10
>> runcmd:
>>  - [ cloud-init-per, once, foreman-userdata, /tmp/foreman-userdata.sh ]
>> output: {all: '| tee -a /root/install.userdata.log'}
>>
>> ---
>>
>> any ideas?
>>
>> BR
>>
>> Christian
>
> --
> 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.



-- 
Later,
  Lukas @lzap Zapletal

-- 
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.

Reply via email to