[ansible-project] Reading partial string

2020-09-20 Thread dudu.c...@gmail.com


Hi, 

I have a simple playbook that takes an IP address from the input file and 
update this IP including hostname under /etc/hosts.

The problem is that in the input file the IP is written with subnet – 
1.1.1.1/24

While I need only the IP  1.1.1.1

 

 *Playbook :*

- hosts: localhost

  become: true

  any_errors_fatal: true

  gather_facts: False

  vars_files:

- /opt/ input-file.yml

  tasks:

 

  - name: Update server etc/host with response ip 

lineinfile:

path: /etc/hosts

line: "{{ lb_ext_ip }}hdfs"

state: present

backup: yes

 

*Result in /etc/hosts*

1.1.1.1/24hdfs

 

*Required results:*

1.1.1.1   hdfs

-- 
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/272a5ee9-5200-4390-98d9-1d51f469b051n%40googlegroups.com.


Re: [ansible-project] Ansible set_fact with with_items always prints last item

2020-09-20 Thread kumare...@gmail.com
Hi Brae,

Thanks for the help was able to get the desired output.But the output are 
in same line is there way to print new line for each service?

TASK [debug] 
***
ok: [test] => {
"msg": "httpd.service Running\nntpd.service Running\n"
}

Expected output:

httpd.service Running 
ntpd.service Running 

Regards
Kumar

On Saturday, 19 September 2020 at 19:28:58 UTC+5:30 brae...@gmail.com wrote:

> On 9/19/20 12:29 PM, kumare...@gmail.com wrote:
> > Hi Experts,
> > 
> > I am looking to capture certain service status using ansible the problem 
> is debug prints only last item.Below is the
> > expected output.
> > 
> > Hostname : test
> > 
> > httpd --> Running
> > ntpd  --> Running
> > 
> > Below are the playbook.
> > 
> > ---
> > - hosts: test
> >   become: true
> >   gather_facts: false
> >   tasks:
> > - name: Service facts
> >   service_facts:
> > 
> > - set_fact:
> >elk_app1: "{{ ansible_facts.services[item + '.service'].name}} 
> Running"
> >   when: ansible_facts.services[item + '.service'].state == 'running'
> >   with_items:
> > - httpd
> > - ntpd
> >   register: foo_result
> > 
> > - debug: msg="{{ foo_result }}"
> > 
> > 
> > Regards
> > Kumar
>
> Hello Kumar,
>
> if you use set_fact with a loop, you need to reference the variable on the 
> right hand side:
>
> set_fact:
> elk_app1: "{{ elk_app1 | default('') + ansible_facts.services[item + 
> '.service'].name + ' Running\n' }}"
>
> The default filter is necessary as the variable is undefined on the first 
> iteration of the loop.
>
> Regards
> Racke
>
> > 
> > -- 
> > 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-proje...@googlegroups.com  ansible-proje...@googlegroups.com>.
> > To view this discussion on the web visit
> > 
> https://groups.google.com/d/msgid/ansible-project/cbd4fd36-e141-48a1-b306-0a9629ec8e31n%40googlegroups.com
> > <
> https://groups.google.com/d/msgid/ansible-project/cbd4fd36-e141-48a1-b306-0a9629ec8e31n%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/48b4d375-f1bf-46fb-a4a5-84e8f89c88een%40googlegroups.com.


Re: [ansible-project] Ansible - url check for multiple hosts

2020-09-20 Thread priyanka prabhune
Thanks, this is working. 

On Saturday, September 19, 2020 at 11:17:51 PM UTC+5:30 
gajendra@gmail.com wrote:

> Try 
> - name: check the url http://{{ inventory_hostname}}:{{ port }}/test
>
> On Sat, 19 Sep 2020, 20:46 priyanka prabhune,  
> wrote:
>
>> I am writing the Ansible playbook to check the URL status for multiple 
>> IPs from the hosts file, however, it is not working when I am giving input 
>> as a group_name, but is working for single IP.
>>
>> Here is my playbook,
>> ---
>> - hosts: "{{ hosts }}" 
>>   vars_prompt: 
>> - name: "hosts" 
>>   prompt: "Please enter the hosts details" 
>>   private: no 
>> - name: "port" 
>>   prompt: "Please enter the port" 
>>   private: no 
>>
>>   serial: 1 
>>   tasks: 
>> - name: check the url http://{{ hosts }}:{{ port }}/test 
>>   uri: 
>>  url: "http://{{ hosts }}:{{ port }}/test" 
>>  follow_redirects: none 
>>  method: GET 
>>  register: _result 
>>  until: _result.status == 200
>>
>> My application is running on below Ips and I want to check the url status 
>> for all.
>> [webservers] 
>> 10.10.10.10 
>> 10.10.10.20 
>> 10.10.10.30 
>> 10.10.10.40 
>>
>> *But it's getting failed with below error.*
>> ansible-playbook test.yml -u test --ask-pass SSH password: [WARNING]: 
>> Invalid characters were found in group names but not replaced, use - to 
>> see details Please enter the hosts details: webservers Please enter the 
>> port: 8080 [WARNING]: Found variable using reserved name: port PLAY 
>> [webservers] 
>> >
>>  
>>  TASK [Gathering Facts] 
>> **
>>  
>> ok: [10.10.10.10] TASK [http://webservers:8080/test] 
>> ** 
>> [WARNING]: The value True (type bool) in a string field was converted to 
>> u'True' (type string). If this does not look like what you expect, quote 
>> the entire value to ensure it does not change. fatal: [10.10.10.10]: 
>> FAILED! => {"changed": false, "content": "", "elapsed": 0, 
>> "failed_when_result": true, "msg": "Status code was -1 and not [200]: 
>> Request failed: ", 
>> "redirected": false, "status": -1, "url": "*http://webservers:8080/test 
>> *"} PLAY RECAP 
>> **
>>  
>> 10.10.10.10 : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 
>> ignored=0 
>>
>> *Can someone please suggest on this?*
>>
>> -- 
>> 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-proje...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/d77b3789-c21e-4dbe-8780-01bb9aab1c8fn%40googlegroups.com
>>  
>> 
>> .
>>
>

-- 
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/defb2b73-387e-452f-b25a-78ad43701bfbn%40googlegroups.com.


Re: [ansible-project] mail module

2020-09-20 Thread Dick Visser
On Sun, 20 Sep 2020 at 15:50, P Music's
 wrote:
>
> I attached my ansible version screen shot and error screenshot please look at 
> this and help me out as soon as possible I stuck up with this problem for a 
> week

Sounds like bad planning on your side.
You might get more help if you provide better information to start
with, and change your attitude.
This list is run by volunteers, so don't order them around.

The issue is with your controller node, it appears to have some
screwed up network configuration.
Check manually if you can set up connections to the specific
host/port, for instance with OpenSSL s_client:

echo "EHLO blah.com" | openssl s_client -starttls smtp -crlf -connect
smtp.gmail.com:587

This should give you a 250 response code. If it doesn't work, then you
need to fix that. If it's fixed, then your ansible playbook should
also work.

PS next time just post actual text if asked, and not some shaky 3MB photo...

Dick


>
> Thanks
> Prajwal h g
>
> On Sun, 20 Sep, 2020, 12:03 PM Dick Visser,  wrote:
>>
>> On Sun, 20 Sep 2020 at 08:24, Dick Visser  wrote:
>>
>> > > sender: "x...@gmail.com"
>> >
>> > There is no 'sender' argument. See
>> > https://docs.ansible.com/ansible/latest/modules/mail_module.html
>>
>> Actually 'sender' is an undocumted alias for 'from', so this will work.
>>
>>
>>
>> --
>> Dick Visser
>> Trust & Identity Service Operations Manager
>> GÉANT
>>
>> --
>> 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/CAL8fbwNg5Dm942_VhoMPu0S_D8qDnDDJ10D1qHUxrmrSs%3DbFnA%40mail.gmail.com.
>
> --
> 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/CAMQ8AOgGaQ-F%3DQ645dAUdA1P-uram0yGQ-PngnoFSzRT8Z1VOQ%40mail.gmail.com.



--
Dick Visser
Trust & Identity Service Operations Manager
GÉANT

-- 
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/CAL8fbwOnoHfHRdCTaZ3N_sKun6RV8daq1oH34MgRfSH2VwBUZQ%40mail.gmail.com.


[ansible-project] using ansible inside wsl2

2020-09-20 Thread Wayne Douglas
Hi

I am trying to use ansible in wsl2 and have started getting errors like:

WARNING: Kubernetes configuration file is group-readable. This is insecure. 
Location: /home/wayne/.kube/config

Has anyone else seen this? Googling doesn't turf up much

-- 
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/04aa947e-2546-4896-987c-f5b9579764c0n%40googlegroups.com.


Re: [ansible-project] mail module

2020-09-20 Thread Dick Visser
On Sun, 20 Sep 2020 at 08:24, Dick Visser  wrote:

> > sender: "x...@gmail.com"
>
> There is no 'sender' argument. See
> https://docs.ansible.com/ansible/latest/modules/mail_module.html

Actually 'sender' is an undocumted alias for 'from', so this will work.



-- 
Dick Visser
Trust & Identity Service Operations Manager
GÉANT

-- 
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/CAL8fbwNg5Dm942_VhoMPu0S_D8qDnDDJ10D1qHUxrmrSs%3DbFnA%40mail.gmail.com.


Re: [ansible-project] mail module

2020-09-20 Thread Dick Visser
On Sat, 19 Sep 2020 at 11:02, P Music's
 wrote:
>
> here is my playbook
> ---
>  - hosts:all
>tasks:
>   -   name: send mail
>   mail:
> host: "smtp.gmail.com"
> port: 587
> sender: "x...@gmail.com"

There is no 'sender' argument. See
https://docs.ansible.com/ansible/latest/modules/mail_module.html


Other than that it looks OK.
So, what is the EXACT error output you get when running the task>?
Also what version etc etc.

And keep in mind Gmail requires an application specific password:
https://support.google.com/mail/answer/185833?hl=en

-- 
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/CAL8fbwN0cXaXgO10GvpGH6DLf0Mx0YSywUoGskP8mb7NAbC6OA%40mail.gmail.com.