[ansible-project] Issue while parsing Complex Regular expression in YAML file

2020-06-03 Thread Pawan Kumar
Issue is coming while parsing the following regular expression 

"^[a-zA-Z0-9-+.#$%&~*\/=?^_ '\"\\!]{9,430}$"


*Tried other options like *



"^[a-zA-Z0-9-+.#$%&~*\/=?^_ '\\\"\\!]{9,430}$"


'^[a-zA-Z0-9-+.#$%&~*\/=?^_ '\"\\!]{9,430}$'


*Issues coming *


  stderr: |-
while scanning a double-quoted scalar
  in "", line 373, column 56:
 ... ex: '^[a-zA-Z0-9-+.#$%&~*/=?^_ '"\!]{9,430}$'

^
found unknown escape character '!'
  in "", line 373, column 58:
 ... : '^[a-zA-Z0-9-+.#$%&~*/=?^_ '"\!]{9,430}$'
 ^




ERROR! Syntax Error while loading YAML.
  expected , but found ''


The offending line appears to be:

context_regex: '''^[a-zA-Z0-9-+.#$%&~*\/=?^_ '\"\\!]{9,430}$'''
   
   ^ here


-

ERROR! Syntax Error while loading YAML.
  found character '`' that cannot start any token


The offending line appears to be:


context_regex: ```^[a-zA-Z0-9-+.#$%&~*\/=?^_ '\"\\!]{9,430}$```
  ^ here

---

ERROR! Syntax Error while loading YAML.
  found character '`' that cannot start any token


context_regex: `^[a-zA-Z0-9-+.#$%&~*\/=?^_ '\"\\!]{9,430}$`
  ^ here


---


ERROR! Syntax Error while loading YAML.
  expected , but found ''

context_regex: '^[a-zA-Z0-9-+.#$%&~*\/=?^_ \'\\\!]{8,240}$'

 
^ here

---

ERROR! Syntax Error while loading YAML.
  expected , but found ''


context_regex: '^[a-zA-Z0-9-+.#$%&~*\/=?^_ \'\\!]{9,430}$'

 ^ here
--

ERROR! Syntax Error while loading YAML.
  expected , but found ''


context_regex: '^[a-zA-Z0-9-+.#$%&~*\/=?^_ \'\\\"\\!]{9,430}$'

  
^ here


--

ERROR! Syntax Error while loading YAML.
  expected , but found ''

context_regex: '^[a-zA-Z0-9-+.#$%&~*\/=?^_ \'\\"\\!]{8,240}$'


  
^ here


---

ERROR! Syntax Error while loading YAML.
  expected , but found ''


context_regex: '^[a-zA-Z0-9-+.#$%&~*\/=?^_ \'\"\\!]{9,430}$'

   
^ here

---


ERROR! Syntax Error while loading YAML.
  found unknown escape character '^'


context_regex: "\\\^[a-zA-Z0-9-+.#$%&~*\/=?^_ '\"\\!]{9,430}$\\\"
^ here


-

ERROR! Syntax Error while loading YAML.
  found unknown escape character '!'


context_regex: "^[a-zA-Z0-9-+.#$%&~*\/=?^_ '\\\!]{9,430}$"

 
^ here

--



-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/1d6cf93c-55dc-4e86-b824-6aae4d33883a%40googlegroups.com.


Re: [ansible-project] Add new line “\n” character to Ansible set_fact variable

2020-06-03 Thread Shifa Shaikh
Stephan Hi, 

The article does not discuss newline inside parenthesis `{{` inside a 
variable definition. That is where I have no clue.

On Thursday, June 4, 2020 at 10:31:41 AM UTC+5:30, Stefan Hornburg (Racke) 
wrote:
>
> On 6/4/20 6:41 AM, Shifa Shaikh wrote: 
> > I tried all of these but have no clue to a solution.  
> > 
> > mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' +  PROFILE_NAME + 
> "\n" + 'SERVER_NAME:' + SERVER_NAME + "\n" + 
> > 'NODE_NAME:' +  NODE_NAME + "\n\n\n\n\" }}" 
> > 
> > mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' +  PROFILE_NAME + 
> '\n' + 'SERVER_NAME:' + SERVER_NAME + '\n' + 
> > 'NODE_NAME:' +  NODE_NAME + '\n\n\n\n\' }}" 
> > 
> > mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' +  PROFILE_NAME ~ 
> }} \n + {{ 'SERVER_NAME:' + SERVER_NAME ~ }} + 
> > \n + {{ 'NODE_NAME:' +  NODE_NAME ~ }} \n\n\n\n\" 
> > 
> > 
>
> Use multiline YAML: https://yaml-multiline.info/ 
>
> Regards 
> Racke 
>
>
> > On Thursday, June 4, 2020 at 2:27:48 AM UTC+5:30, Shifa Shaikh wrote: 
> > 
> > @Dick VIsser Hi,  
> > 
> > Upon your suggestion, I tried something like this but it too does 
> not work. 
> > 
> > | 
> >-set_fact: 
> > 
> >mailbody:"{{ mailbody | default('') + 'PROFILE_NAME:' + 
>  PROFILE_NAME ~ \"\n\n\"'SERVER_NAME:' + SERVER_NAME 
> > ~ \"\n\n\"'NODE_NAME:' +  NODE_NAME ~ \"\n\n\n\n\" }}" 
> > | 
> > 
> > Can someone please suggest? 
> > 
> > On Wednesday, June 3, 2020 at 11:49:10 PM UTC+5:30, Dick Visser 
> wrote: 
> > 
> > I won't comment on whatever it is you're trying to do, but in 
> any case you need to use double quotes around the 
> > newlines  
> > 
> > On Wed, 3 Jun 2020 at 20:12, Shifa Shaikh  
> wrote: 
> > 
> > How can I add new line characters to Ansible 
> variable |mailbody. This mailbody variable is used for mail 
> > module's body attribute.| 
> > 
> > | 
> > | 
> > 
> > I tried the below from suggestions but none of them works.  
> > 
> > 
> > |1. | 
> > 
> > |- set_fact: mailbody: "{{ mailbody | default('') + 
> 'PROFILE_NAME:' + PROFILE_NAME ~ '\n\nSERVER_NAME:' + 
> > SERVER_NAME ~ '\n\nNODE_NAME:' + NODE_NAME ~ '\n\n\n\n' }}"| 
> > 
> > |2.| 
> > 
> >   mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' 
> +  PROFILE_NAME ~}} {{ 'SERVER_NAME:' + SERVER_NAME ~ }}\n\n{{'NODE_NAME:' 
> +  NODE_NAME ~ }}\n\n\n\n" 
> > 
> > 3. 
> > 
> > |mailbody: | "{{ mailbody | default('') + 'PROFILE_NAME:' + 
> PROFILE_NAME ~}}" "{{ 'SERVER_NAME:' + 
> > SERVER_NAME ~ }}" "{{'NODE_NAME:' + NODE_NAME ~ }}"| 
> > 
> > In the mail body i see '\n' instead of the new line 
> charecter. 
> > 
> > Can you please suggest ? 
> > 
> > 
> > | 
> > | 
> > 
> > -- 
> > 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 ansible...@googlegroups.com. 
> > To view this discussion on the web visit 
> > 
> https://groups.google.com/d/msgid/ansible-project/c9a4818e-dab2-4ad8-8d6c-c477e8915193%40googlegroups.com
>  
> > <
> https://groups.google.com/d/msgid/ansible-project/c9a4818e-dab2-4ad8-8d6c-c477e8915193%40googlegroups.com?utm_medium=email_source=footer>.
>  
>
> > 
> > -- 
> > Sent from a mobile device - please excuse the brevity, spelling 
> and punctuation. 
> > 
> > -- 
> > 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 
> > ansible...@googlegroups.com   ansible-project+unsubscr...@googlegroups.com >. 
> > To view this discussion on the web visit 
> > 
> https://groups.google.com/d/msgid/ansible-project/1515dc41-ed08-4ade-b09f-455a922497c8%40googlegroups.com
>  
> > <
> https://groups.google.com/d/msgid/ansible-project/1515dc41-ed08-4ade-b09f-455a922497c8%40googlegroups.com?utm_medium=email_source=footer>.
>  
>
>
>
> -- 
> Ecommerce and Linux consulting + Perl and web application programming. 
> Debian and Sympa administration. Provisioning with Ansible. 
>
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/ea570673-e541-4207-81c8-84d4353b8572%40googlegroups.com.


Re: [ansible-project] Add new line “\n” character to Ansible set_fact variable

2020-06-03 Thread Stefan Hornburg (Racke)
On 6/4/20 6:41 AM, Shifa Shaikh wrote:
> I tried all of these but have no clue to a solution. 
> 
> mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' +  PROFILE_NAME + "\n" 
> + 'SERVER_NAME:' + SERVER_NAME + "\n" +
> 'NODE_NAME:' +  NODE_NAME + "\n\n\n\n\" }}"
> 
> mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' +  PROFILE_NAME + '\n' 
> + 'SERVER_NAME:' + SERVER_NAME + '\n' +
> 'NODE_NAME:' +  NODE_NAME + '\n\n\n\n\' }}"
> 
> mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' +  PROFILE_NAME ~ }} 
> \n + {{ 'SERVER_NAME:' + SERVER_NAME ~ }} +
> \n + {{ 'NODE_NAME:' +  NODE_NAME ~ }} \n\n\n\n\"
> 
> 

Use multiline YAML: https://yaml-multiline.info/

Regards
Racke


> On Thursday, June 4, 2020 at 2:27:48 AM UTC+5:30, Shifa Shaikh wrote:
> 
> @Dick VIsser Hi, 
> 
> Upon your suggestion, I tried something like this but it too does not 
> work.
> 
> |
>    -set_fact:
> 
>        mailbody:"{{ mailbody | default('') + 'PROFILE_NAME:' +  
> PROFILE_NAME ~ \"\n\n\"'SERVER_NAME:' + SERVER_NAME
> ~ \"\n\n\"'NODE_NAME:' +  NODE_NAME ~ \"\n\n\n\n\" }}"
> |
> 
> Can someone please suggest?
> 
> On Wednesday, June 3, 2020 at 11:49:10 PM UTC+5:30, Dick Visser wrote:
> 
> I won't comment on whatever it is you're trying to do, but in any 
> case you need to use double quotes around the
> newlines 
> 
> On Wed, 3 Jun 2020 at 20:12, Shifa Shaikh  wrote:
> 
> How can I add new line characters to Ansible variable |mailbody. 
> This mailbody variable is used for mail
> module's body attribute.|
> 
> |
> |
> 
> I tried the below from suggestions but none of them works. 
> 
> 
> |1. |
> 
> |- set_fact: mailbody: "{{ mailbody | default('') + 
> 'PROFILE_NAME:' + PROFILE_NAME ~ '\n\nSERVER_NAME:' +
> SERVER_NAME ~ '\n\nNODE_NAME:' + NODE_NAME ~ '\n\n\n\n' }}"|
> 
> |2.|
> 
>   mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' +  
> PROFILE_NAME ~}} {{ 'SERVER_NAME:' + SERVER_NAME ~ }}\n\n{{'NODE_NAME:' +  
> NODE_NAME ~ }}\n\n\n\n"
> 
> 3.
> 
> |mailbody: | "{{ mailbody | default('') + 'PROFILE_NAME:' + 
> PROFILE_NAME ~}}" "{{ 'SERVER_NAME:' +
> SERVER_NAME ~ }}" "{{'NODE_NAME:' + NODE_NAME ~ }}"|
> 
> In the mail body i see '\n' instead of the new line charecter. 
> 
> Can you please suggest ?
> 
> 
> |
> |
> 
> -- 
> 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 ansible...@googlegroups.com.
> To view this discussion on the web visit
> 
> https://groups.google.com/d/msgid/ansible-project/c9a4818e-dab2-4ad8-8d6c-c477e8915193%40googlegroups.com
> 
> .
> 
> -- 
> Sent from a mobile device - please excuse the brevity, spelling and 
> punctuation.
> 
> -- 
> 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
> ansible-project+unsubscr...@googlegroups.com 
> .
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/1515dc41-ed08-4ade-b09f-455a922497c8%40googlegroups.com
> .


-- 
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/9151b720-fc60-3fae-cf2f-dda46ec4f711%40linuxia.de.


signature.asc
Description: OpenPGP digital signature


Re: [ansible-project] Add new line “\n” character to Ansible set_fact variable

2020-06-03 Thread Shifa Shaikh
I tried all of these but have no clue to a solution. 

mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' +  PROFILE_NAME + 
"\n" + 'SERVER_NAME:' + SERVER_NAME + "\n" + 'NODE_NAME:' +  NODE_NAME + 
"\n\n\n\n\" }}"

mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' +  PROFILE_NAME + 
'\n' + 'SERVER_NAME:' + SERVER_NAME + '\n' + 'NODE_NAME:' +  NODE_NAME + 
'\n\n\n\n\' }}"

mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' +  PROFILE_NAME ~ }} 
\n + {{ 'SERVER_NAME:' + SERVER_NAME ~ }} + \n + {{ 'NODE_NAME:' + 
 NODE_NAME ~ }} \n\n\n\n\"


On Thursday, June 4, 2020 at 2:27:48 AM UTC+5:30, Shifa Shaikh wrote:
>
> @Dick VIsser Hi, 
>
> Upon your suggestion, I tried something like this but it too does not work.
>
>- set_fact:
>
>mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' + 
>  PROFILE_NAME ~ \"\n\n\"'SERVER_NAME:' + SERVER_NAME ~ \"\n\n\"'NODE_NAME:' 
> +  NODE_NAME ~ \"\n\n\n\n\" }}"
>
> Can someone please suggest?
>
> On Wednesday, June 3, 2020 at 11:49:10 PM UTC+5:30, Dick Visser wrote:
>>
>> I won't comment on whatever it is you're trying to do, but in any case 
>> you need to use double quotes around the newlines 
>>
>> On Wed, 3 Jun 2020 at 20:12, Shifa Shaikh  wrote:
>>
>>> How can I add new line characters to Ansible variable mailbody. This 
>>> mailbody variable is used for mail module's body attribute.
>>>
>>>
>>> I tried the below from suggestions but none of them works. 
>>>
>>>
>>> 1. 
>>>
>>>   - set_fact:
>>>mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' +  
>>> PROFILE_NAME ~ '\n\nSERVER_NAME:' + SERVER_NAME ~ '\n\nNODE_NAME:' +  
>>> NODE_NAME ~ '\n\n\n\n' }}"
>>>
>>> 2.
>>>
>>>   mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' +  
>>> PROFILE_NAME ~}} {{ 'SERVER_NAME:' + SERVER_NAME ~ }}\n\n{{'NODE_NAME:' +  
>>> NODE_NAME ~ }}\n\n\n\n"
>>>
>>> 3.
>>>
>>>  mailbody: | 
>>>  "{{ mailbody | default('') + 'PROFILE_NAME:' +  PROFILE_NAME ~}}"
>>>  "{{ 'SERVER_NAME:' + SERVER_NAME ~ }}"
>>>  "{{'NODE_NAME:' +  NODE_NAME ~ }}"
>>>
>>> In the mail body i see '\n' instead of the new line charecter. 
>>>
>>> Can you please suggest ?
>>>
>>>
>>>
>>> -- 
>>> 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 ansible...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/ansible-project/c9a4818e-dab2-4ad8-8d6c-c477e8915193%40googlegroups.com
>>>  
>>> 
>>> .
>>>
>> -- 
>> Sent from a mobile device - please excuse the brevity, spelling and 
>> punctuation.
>>
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/1515dc41-ed08-4ade-b09f-455a922497c8%40googlegroups.com.


Re: [ansible-project] Add new line “\n” character to Ansible set_fact variable

2020-06-03 Thread Shifa Shaikh
@Dick VIsser Hi, 

Upon your suggestion, I tried something like this but it too does not work.

   - set_fact:

   mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' + 
 PROFILE_NAME ~ \"\n\n\"'SERVER_NAME:' + SERVER_NAME ~ \"\n\n\"'NODE_NAME:' 
+  NODE_NAME ~ \"\n\n\n\n\" }}"

Can someone please suggest?

On Wednesday, June 3, 2020 at 11:49:10 PM UTC+5:30, Dick Visser wrote:
>
> I won't comment on whatever it is you're trying to do, but in any case you 
> need to use double quotes around the newlines 
>
> On Wed, 3 Jun 2020 at 20:12, Shifa Shaikh > 
> wrote:
>
>> How can I add new line characters to Ansible variable mailbody. This 
>> mailbody variable is used for mail module's body attribute.
>>
>>
>> I tried the below from suggestions but none of them works. 
>>
>>
>> 1. 
>>
>>   - set_fact:
>>mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' +  
>> PROFILE_NAME ~ '\n\nSERVER_NAME:' + SERVER_NAME ~ '\n\nNODE_NAME:' +  
>> NODE_NAME ~ '\n\n\n\n' }}"
>>
>> 2.
>>
>>   mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' +  PROFILE_NAME 
>> ~}} {{ 'SERVER_NAME:' + SERVER_NAME ~ }}\n\n{{'NODE_NAME:' +  NODE_NAME ~ 
>> }}\n\n\n\n"
>>
>> 3.
>>
>>  mailbody: | 
>>  "{{ mailbody | default('') + 'PROFILE_NAME:' +  PROFILE_NAME ~}}"
>>  "{{ 'SERVER_NAME:' + SERVER_NAME ~ }}"
>>  "{{'NODE_NAME:' +  NODE_NAME ~ }}"
>>
>> In the mail body i see '\n' instead of the new line charecter. 
>>
>> Can you please suggest ?
>>
>>
>>
>> -- 
>> 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 ansible...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/c9a4818e-dab2-4ad8-8d6c-c477e8915193%40googlegroups.com
>>  
>> 
>> .
>>
> -- 
> Sent from a mobile device - please excuse the brevity, spelling and 
> punctuation.
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/9f876182-b951-4dc2-b6c6-dd6eb7b17c28%40googlegroups.com.


Re: [ansible-project] Convert Ansible playbook to bash script

2020-06-03 Thread Dick Visser
Hi

It would help if you come up with actual playbooks and a (better)
description of what this is actually about.
I see a few random technology names like vagrant, virtual box, EC2 but
those mean nothing without context.
You will get the best results with specific questions about Ansible related
issues.
On the other hand, reverse engineering documentation from abandoned
playbooks might not yield too many responses.




On Wed, 3 Jun 2020 at 20:30, Sushant Sawant 
wrote:

> Hi guys,
>
> Little bit of background, I have a project which has ansible playbook
> vagrant installation. This runs on my local machine Ubuntu 18.04
>
> There is no developer working on this, I have no experience on ansible.
>
> To take this to server, ansible is unable to access  port on virtual
> box on EC2 instance. After googling stuffs I find, running another virtual
> machine on EC2 is not allowed, as EC2 itself is an virtual machine.
>
> So as an solution, I thought of running this ansible playbook on localhost
> of EC2 instance. The playbook ran successfully with no error but it missed
> lots of settings or rather skipped.
>
> If I can get bash scripts from ansible helps me to understand parameter,
> variables required.
>
> Any new idea helps..
>
> Thanks,
> Sushant
>
> --
> 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 ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/c60b40c4-d5bf-4779-9418-fe15f811cb08%40googlegroups.com
> 
> .
>
-- 
Sent from a mobile device - please excuse the brevity, spelling and
punctuation.

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAL8fbwNoPagQgc1h6pbF-OWHpZphhTectPq2%2BiYJ5iApXmWJVg%40mail.gmail.com.


[ansible-project] Convert Ansible playbook to bash script

2020-06-03 Thread Sushant Sawant
Hi guys,

Little bit of background, I have a project which has ansible playbook 
vagrant installation. This runs on my local machine Ubuntu 18.04

There is no developer working on this, I have no experience on ansible.

To take this to server, ansible is unable to access  port on virtual 
box on EC2 instance. After googling stuffs I find, running another virtual 
machine on EC2 is not allowed, as EC2 itself is an virtual machine.

So as an solution, I thought of running this ansible playbook on localhost 
of EC2 instance. The playbook ran successfully with no error but it missed 
lots of settings or rather skipped.

If I can get bash scripts from ansible helps me to understand parameter, 
variables required.

Any new idea helps..

Thanks,
Sushant

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/c60b40c4-d5bf-4779-9418-fe15f811cb08%40googlegroups.com.


Re: [ansible-project] Add new line “\n” character to Ansible set_fact variable

2020-06-03 Thread Dick Visser
I won't comment on whatever it is you're trying to do, but in any case you
need to use double quotes around the newlines

On Wed, 3 Jun 2020 at 20:12, Shifa Shaikh  wrote:

> How can I add new line characters to Ansible variable mailbody. This
> mailbody variable is used for mail module's body attribute.
>
>
> I tried the below from suggestions but none of them works.
>
>
> 1.
>
>   - set_fact:
>mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' +  PROFILE_NAME 
> ~ '\n\nSERVER_NAME:' + SERVER_NAME ~ '\n\nNODE_NAME:' +  NODE_NAME ~ 
> '\n\n\n\n' }}"
>
> 2.
>
>   mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' +  PROFILE_NAME 
> ~}} {{ 'SERVER_NAME:' + SERVER_NAME ~ }}\n\n{{'NODE_NAME:' +  NODE_NAME ~ 
> }}\n\n\n\n"
>
> 3.
>
>  mailbody: |
>  "{{ mailbody | default('') + 'PROFILE_NAME:' +  PROFILE_NAME ~}}"
>  "{{ 'SERVER_NAME:' + SERVER_NAME ~ }}"
>  "{{'NODE_NAME:' +  NODE_NAME ~ }}"
>
> In the mail body i see '\n' instead of the new line charecter.
>
> Can you please suggest ?
>
>
>
> --
> 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 ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/c9a4818e-dab2-4ad8-8d6c-c477e8915193%40googlegroups.com
> 
> .
>
-- 
Sent from a mobile device - please excuse the brevity, spelling and
punctuation.

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAL8fbwOWhpVoNHNdvfXzy7YXoWGnvw4MhN5FUE3H-fphPyHgpA%40mail.gmail.com.


[ansible-project] Add new line “\n” character to Ansible set_fact variable

2020-06-03 Thread Shifa Shaikh


How can I add new line characters to Ansible variable mailbody. This 
mailbody variable is used for mail module's body attribute.


I tried the below from suggestions but none of them works. 


1. 

  - set_fact:
   mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' +  PROFILE_NAME ~ 
'\n\nSERVER_NAME:' + SERVER_NAME ~ '\n\nNODE_NAME:' +  NODE_NAME ~ '\n\n\n\n' 
}}"

2.

  mailbody: "{{ mailbody | default('') + 'PROFILE_NAME:' +  PROFILE_NAME 
~}} {{ 'SERVER_NAME:' + SERVER_NAME ~ }}\n\n{{'NODE_NAME:' +  NODE_NAME ~ 
}}\n\n\n\n"

3.

 mailbody: | 
 "{{ mailbody | default('') + 'PROFILE_NAME:' +  PROFILE_NAME ~}}"
 "{{ 'SERVER_NAME:' + SERVER_NAME ~ }}"
 "{{'NODE_NAME:' +  NODE_NAME ~ }}"

In the mail body i see '\n' instead of the new line charecter. 

Can you please suggest ?



-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/c9a4818e-dab2-4ad8-8d6c-c477e8915193%40googlegroups.com.


Re: [ansible-project] aws community edition and collection

2020-06-03 Thread Matt Martz
Largely the split was done between what was previously "core" supported and
what was community supported.

amazon.aws is supported by Red Hat/Ansible employees, and community.aws is
technically supported by the community.

New modules/plugins should almost definitely be submitted to community.aws,
and if it is deemed it should be supported, it can be moved at a later date.

On Wed, Jun 3, 2020 at 10:40 AM Sydo Luciani  wrote:

> aws modules have been redirected/moved to two different repositories, some
> to community.aws and some to amazon.aws
>
> https://github.com/ansible-collections/amazon.aws
> https://github.com/ansible-collections/community.aws
>
>
> My first question is, what was the criteria for moving each modules to
> different repositories ? so we know the correct place to submit future aws
> modules !!! is there a change log for this move ?
>
> My second question is for those with more experience with Ansible and
> github:
> isn't better to make the amazon.aws plugin directory be the sub
> repository/sub module/fork or mirror of community.aws plugin directory ?
> this way modules and plugins version and code stay the same in both, while
> one will be used as collection and one as module 
>
> Thanks
>
> --
> 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 ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAJspodgXNZsv1BvE1GtTWPrLW_b9o-wAs%3Dt5np1-xa1kKJJ%3D2w%40mail.gmail.com
> 
> .
>


-- 
Matt Martz
@sivel
sivel.net

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAD8N0v8V%2Brw%3DV6_59mR0X6CZDp2WZmL3nOz-k3k7Po5vf1Kauw%40mail.gmail.com.


[ansible-project] aws community edition and collection

2020-06-03 Thread Sydo Luciani
aws modules have been redirected/moved to two different repositories, some
to community.aws and some to amazon.aws

https://github.com/ansible-collections/amazon.aws
https://github.com/ansible-collections/community.aws


My first question is, what was the criteria for moving each modules to
different repositories ? so we know the correct place to submit future aws
modules !!! is there a change log for this move ?

My second question is for those with more experience with Ansible and
github:
isn't better to make the amazon.aws plugin directory be the sub
repository/sub module/fork or mirror of community.aws plugin directory ?
this way modules and plugins version and code stay the same in both, while
one will be used as collection and one as module 

Thanks

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAJspodgXNZsv1BvE1GtTWPrLW_b9o-wAs%3Dt5np1-xa1kKJJ%3D2w%40mail.gmail.com.


Re: [ansible-project] Getting the version of an Ansible Galaxy role

2020-06-03 Thread Brian Coca
if they are your roles a _rolname_version in vars/main.yml would be a
good workaround.





-- 
--
Brian Coca

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CACVha7cfrKDp6FL99TDeEd0ftHiyYD_fEozmO9HOZ_bqh%2BXtfQ%40mail.gmail.com.


Re: [ansible-project] With_items /pass var - string.

2020-06-03 Thread Dick Visser
All the looping constructs (with_items etc) assume you have some data
structure that is iterable, ie. a list, a dict, etc.
>From your vars file it seems (guessing here) that you want to iterate
over multiple independent variables.
If that is the case, I would suggest restructuring those multiple vars
to one iterable var.
This will give you a lot more flexibility elsewhere in your deployment as well.

For example:

allsizes:
  - config: "DC2019"
name: small2019
InstallMedia:
  Source: "someshare\\"
  SourceVHDX: "Virtual Hard Disks\\DC2019.vhdx"
  Destination: "C:\\ISOs\\MDT\\DC2019\\"
  - config: "DC2019"
name: large2019
InstallMedia:
  Source: "someshare\\"
  SourceVHDX: "Virtual Hard Disks\\DC2019.vhdx"
  Destination: "C:\\ISOs\\MDT\\DC2019\\"

(Note that apart from the name (which used to be your variable name),
the dicts are exactly the same - I guess this is just example data and
in reality these actually differ)


If this is now what you want, then explain better what you do want. I
would help if you provide real world examples.



On Tue, 2 Jun 2020 at 21:39, Adam McGill  wrote:
>
> Basically i have a include_vars file that has all my configs, want with_items 
> to only pull back the required config.
>
> example / include_vars:
> ---
> small2019:
>   - config: "DC2019"
> InstallMedia:
>   Source: "someshare\\"
>   SourceVHDX: "Virtual Hard Disks\\DC2019.vhdx"
>   Destination: "C:\\ISOs\\MDT\\DC2019\\"
>
> large2019:
>   - config: "DC2019"
> InstallMedia:
>   Source: "someshare\\"
>   SourceVHDX: "Virtual Hard Disks\\DC2019.vhdx"
>   Destination: "C:\\ISOs\\MDT\\DC2019\\"
>
> On Tuesday, June 2, 2020 at 2:36:05 PM UTC-5, Adam McGill wrote:
>>
>> If i remove the single quotes, in the debug i see it pull the information 
>> correctly from the include_vars.  If I use the same with_items: "{{ 
>> vm_config }}" in the task i get this.
>>
>> "msg": "The task includes an option with an undefined variable. The error 
>> was: 'ansible.utils.unsafe_proxy.AnsibleUnsafeText object' has no attribute 
>> 'InstallMedia'\n\nThe error appears to be in
>>
>> On Tuesday, June 2, 2020 at 2:06:39 PM UTC-5, Stefan Hornburg (Racke) wrote:
>>>
>>> On 6/2/20 5:55 PM, Adam McGill wrote:
>>> > I would like to take the value of the var and pass it into with_items and 
>>> > I am running into an issue / error, how can i
>>> > pass just the value into with_items.  If i hardcode and put the value 
>>> > with_items: {{ small2019 }} in there are no
>>> > issues.  Using include_vars / file which has the data, want to pass value 
>>> > into with items to get results.
>>>
>>> Why did you wrap the variable in single quotes? This makes it a literal 
>>> string instead of the contents of the variable ...
>>>
>>> Regards
>>>   Racke
>>>
>>> >
>>> > Result:
>>> > 
>>> > - debug:
>>> > var:  "{{ 'vm_config' }}"
>>> >
>>> > okL  [(servername)] => {
>>> >   "vm_config": "small2019"
>>> > }
>>> >
>>> > Using with_items with value, errors
>>> > 
>>> > - name: Create VMs
>>> >   win_hyperv_guest:
>>> > vmname: "{{ vm_name }}"
>>> > hvhostname: "{{ hv_fullname }}"
>>> > installmedia_source: "{{ item.InstallMedia.Source }}"
>>> > installmedia_destination: "{{ item.InstallMedia.Destination }}"
>>> > importvmoptions_path: "{{ item.ImportVMOptions.Path }}"
>>> > importvmoptions_destination: "{{ item.ImportVMOptions.Destination }}"
>>> > systemosdisksize: "{{ item.SystemOSDiskSize | default (omit) }}"
>>> > vmmemory: "{{ item.VMMemory }}"
>>> > vmprocessor: "{{ item.VMProcessor }}"
>>> > vmnetworkadaptervlan: "{{ item.VMNetworkAdapterVlan }}"
>>> > vmnetworkadapter: "{{ item.VMNetworkAdapter | default (omit) }}"
>>> > additionaldisks: "{{ item.AdditionalDisks | default (omit) }}"
>>> > failoverclusteradd: "{{ item.FailoverClusterAdd | default (omit) }}"
>>> > removedvdrive: "{{ item.RemoveDVDrive | default (omit) }}"
>>> > bootordergen2networklast: "{{ item.BootOrderGen2NetworkLast | default 
>>> > (omit) }}"
>>> > state: present
>>> >   with_items: "{{ 'vm_config' }}"
>>> >   register: new_vms
>>> >
>>> > Using with_items with hardcoded - works
>>> > 
>>> > - name: Create VMs
>>> >   win_hyperv_guest:
>>> > vmname: "{{ vm_name }}"
>>> > hvhostname: "{{ hv_fullname }}"
>>> > installmedia_source: "{{ item.InstallMedia.Source }}"
>>> > installmedia_destination: "{{ item.InstallMedia.Destination }}"
>>> > importvmoptions_path: "{{ item.ImportVMOptions.Path }}"
>>> > importvmoptions_destination: "{{ item.ImportVMOptions.Destination }}"
>>> > systemosdisksize: "{{ item.SystemOSDiskSize | default (omit) }}"
>>> > vmmemory: "{{ item.VMMemory }}"
>>> > vmprocessor: "{{ item.VMProcessor }}"

Re: [ansible-project] Passing variables between hosts

2020-06-03 Thread Dick Visser
You seem to be trying to terminate an instance from that very instance?
That doesn't sound like it would work.
You should use another host.


On Wed, 3 Jun 2020 at 07:57, Andrew Morgan  wrote:

> Hello all,
>
> I have a playbook that is 99% complete but fails on the last step.My
> inventory file and playbook are below. I only added the last parts
>
> [dev]
> dev_jenkins  ansible_ssh_host=44.244.444.44
> ansible_python_interpreter=/usr/bin/python27
> will have multiple servers
>
> [dev:vars]
> ansible_ssh_user=atest
> ansible_ssh_private_key_file=/Users/confluence/Desktop/atest
> ansible_become_user=root
> ansible_become_method=sudo
> ansible_become_password=changeme
> ansible_ssh_pass= changeme
>
> [test]
>
>
> [test:vars]
> ansible_ssh_user=atest
> ansible_ssh_private_key_file=/Users/confluence/Desktop/atest
> ansible_become_user=root
> ansible_become_method=sudo
> ansible_become_password= changeme
> ansible_ssh_pass= changeme
>
>
>
> 1)takes image of live server
> 2)launches the server
> 3)verify login
> 4)kill the server
>
> The issue I am having is with killing the server - name:
> Terminate instances that were previously launched
>
> - hosts: all
>
> - name: Launch instance
> ec2:
>   key_name: ansible
>   group: "{{ group }}"
>   instance_type: m1.small
>   image: "{{ image }}"
>   wait: true
>   region: "{{ region }}"
>   vpc_subnet_id: "{{ subnet}}"
>   assign_public_ip: yes
> register: ec2
>
>   - name: Add new instance to host group
> add_host:
>   hostname: "{{ item.public_ip }}"
>   groupname: test
> loop: "{{ ec2.instances }}"
>
>   - name: Waiting for SSH to come up
> delegate_to: "{{ item.public_ip }}"
> wait_for_connection:
>   delay: 60
>   timeout: 320
> loop: "{{ ec2.instances }}"
>
>
>
> - hosts: test. ##blank in the inventory file, but new instance added to
> it so i can connect to the new instance with password and key
>   become: True
>   gather_facts: True
>
>   tasks:
>
>   - name: Testing out the servers
> shell: ". /etc/profile; echo $DEV_ENV"
> args:
>   executable: /bin/bash
> register: ENTRY
>
>   - name: Output for test server
> debug: msg="{{ ENTRY.stdout }}"
>
>
>   - name: getting instance id again
> shell: "wget -q -O - http://
> 169.254.169.254/latest/meta-data/instance-id"
> register: instanceterminate
>
>   - name: Terminate instances that were previously launched
> ec2:
>   state: 'absent'
>   instance_ids: "{{ instanceterminate.stdout }}"
>   region: us-east-1
># when: ENTRY.rc == 0  or ENTRY.rc >= 2
>
> Problem:
>
> In my inventory file, I have unique parameters per host like
> *ansible_python_interpreter=/usr/bin/python27* , maybe different for each
> server. So when I add the newly spun up instance from the freshly taken ami
> I add it to a group called test which is blank in my inventory file(it has
> the key and password needed to login into the machine.) I do not know of a
> way to specify the  *ansible_python_interpreter *that was used to be used
> again in this last step and I cannot specify it because it will change from
> server to server, and so commands to terminate the instance gives error.
>
> changed=false
>   msg: boto required for this module
>
>
>
> Is there a way I can make this work?
>
> Thank you
>
>
> --
> 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 ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/0c3c8f5d-3db3-4dba-90b5-c195757d0eff%40googlegroups.com
> 
> .
>
-- 
Sent from a mobile device - please excuse the brevity, spelling and
punctuation.

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAL8fbwNoBVG3dwz5ssB7SyNHp%2Be9_dYtEXHJ4VEwMpAg2QpdRg%40mail.gmail.com.