And your question is....?

On Wed, 15 Feb 2023 at 21:07, Cesar Ramirez <[email protected]>
wrote:

> Hello Guys, new tot this Group, trying to provision an EC2 Windows  using
> Ansible with user_data.
>
> On Friday, October 7, 2016 at 5:21:06 PM UTC-7 einarc wrote:
>
>> Hey,
>>
>> You want to put your data in a variable, let's say in /defaults/main.yml
>> and then invoke that from the ec2_lc module:
>>
>>  - ec2_lc:
>>         name: "{{env}}-render-premium-{{gitsha}}"
>>         ...
>>         user_data: "{ {my_user_data }}"
>>
>> I did that exact thing for Launch Configs and it works prefectly.
>>
>> Other than that you may try to rewrite your do to include the pipe WITHIN
>> the brackets. But I wouldn't recommend that as a best practice.
>>
>>
>>      - ec2_lc:
>>         name: "{{env}}-render-premium-{{gitsha}}"
>>         ...
>>         user_data:
>>           { |
>>             "services": ["worker-render-premium@4100"],
>>             "autoScalingGroupName": "{{env}}-render-premium"
>>           }
>>
>>
>> my_user_data: |
>>                         #!/bin/bash
>>            echo "Defaults:{{admin_user}} !requiretty" > /etc/sudoers.d/
>> disable_requiretty
>>
>> And then use that variable from within the module:
>>
>>
>> On Monday, December 7, 2015 at 7:11:31 AM UTC-8, Bryan Larsen wrote:
>>>
>>> On Friday, 26 December 2014 05:05:33 UTC-5, Catalin Costache wrote:
>>>>
>>>> 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
>>>>
>>>
>>> I'm having trouble using this notation.
>>>
>>>      - ec2_lc:
>>>         name: "{{env}}-render-premium-{{gitsha}}"
>>>         ...
>>>         user_data: |
>>>           {
>>>             "services": ["worker-render-premium@4100"],
>>>             "autoScalingGroupName": "{{env}}-render-premium"
>>>           }
>>>
>>> but when I do a `curl http://169.254.169.254/latest/user-data`
>>> <http://169.254.169.254/latest/user-data> to read it back I get:
>>>
>>>     {'services': ['worker-render-premium@4100'],
>>> 'autoScalingGroupName': 'staging-render-premium'}
>>>
>>> The loss of whitespace I can deal with, but translating double quotes
>>> into single quotes makes this invalid JSON and breaks things.
>>>
>>> I'm using ansible 1.9.4.   Even with -vvvv user_data isn't printed.
>>>
>> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/a876f870-7867-4bc7-b20e-10175ee9659en%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/a876f870-7867-4bc7-b20e-10175ee9659en%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
-- 
Sent from Gmail Mobile

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAF8BbLYNJExpVmB5ugSr3PDK_sMcHg6GHtZsLShy-os7_b5TSA%40mail.gmail.com.

Reply via email to