Yaml has a notation for multiline string. I set user data like so:
user_data: |
#!/bin/bash
echo "Defaults:{{admin_user}} !requiretty" > /etc/sudoers.d/
disable_requiretty
Note the pipeline character.
# Join multiple lines without new line
value: >
part 1
part 2
# Join with newline
value2: |
line 1
line 2
On Friday, October 24, 2014 7:06:22 PM UTC+3, Erick Barros wrote:
>
> I got the following error:
>
> ERROR: Syntax Error while loading YAML script, /etc/ansible/playbooks/
> search/roles/aws/tasks/main.yml
> Note: The error may actually appear before this position: line 13, column
> 17
>
>
> state: running
> user_data: """#!/bin/bash
> ^
> This one looks easy to fix. It seems that there is a value started
> with a quote, and the YAML parser is expecting to see the line ended
> with the same kind of quote. For instance:
>
>
> when: "ok" in result.stdout
>
>
> Could be written as:
>
>
> when: '"ok" in result.stdout'
>
>
> or equivalently:
>
>
> when: "'ok' in result.stdout"
>
>
>
>
>
>
> On Saturday, August 16, 2014 12:04:59 PM UTC-3, Michael DeHaan wrote:
>>
>> (a) can you please show the line from your playbook where you are using
>> the user data variable?
>>
>> (b) with the above, how are you determining the way it fails? I.e. what
>> does failure look like?
>>
>>
>> On Fri, Aug 15, 2014 at 5:36 PM, Jonathan Nakatsui <[email protected]>
>> wrote:
>>
>>> From the ansible docs the ec2 module (
>>> http://docs.ansible.com/ec2_module.html) mentions a user_data field.
>>> However, there is no example showing the use of user_data.
>>>
>>> I've tried a variety of things to pass through to the user field to no
>>> avail including
>>>
>>> user_data: file.txt
>>>
>>> user_data: "{{ lookup('file', file.txt') }}"
>>>
>>> user_data: """#!/bin/bash
>>> apt-get update
>>> apt-get install htop"""
>>>
>>> And variations thereof. My googlefu has failed me so far to find any
>>> results for how to solve this issue.
>>>
>>> Thanks if you have any input.
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Ansible Project" 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].
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/ansible-project/64b86c47-036a-471f-8a64-9cbd38c04f5c%40googlegroups.com
>>>
>>> <https://groups.google.com/d/msgid/ansible-project/64b86c47-036a-471f-8a64-9cbd38c04f5c%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" 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].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/651cc196-aa92-4af1-a11f-3e9a05142219%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.