[ansible-project] interprete_python error..

2022-06-16 Thread 'Shivakumar Venkataswamy' via Ansible Project
Hi team,
I'm traying to install python modules.. during execute facing below error.. 
please help me out..

An exception occurred during task execution. To see the full traceback, use 
-vvv. The error was: ImportError: No module named pkg_resources
fatal: [172.16.13.160]: FAILED! => {"changed": false, "msg": "Failed to 
import the required Python library (setuptools) on 172.16.13.160's Python 
/usr/bin/python. Please read module documentation and install in the 
appropriate location. If the required library is installed, but Ansible is 
using the wrong Python interpreter, please consult the documentation on 
ansible_python_interpreter"}

-- 
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/3ddc914f-11b4-4996-98e2-6d5a3d76a444n%40googlegroups.com.


[ansible-project] How to manage ansible-playbook output in jenkins.

2022-06-16 Thread 'Leandro Montesoro' via Ansible Project
Hi!

I have a Jenkins job running an ansible playbook. I need to extract and 
analyze the console output to make a report (csv for example) of the "PLAY 
RECAP" part where I am interested in collecting the failed records 
"failed=1". What is the best way to make it?


Regards!

-- 
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/d917711f-cdfe-4ca8-a3db-55ee9b04cd80n%40googlegroups.com.


Re: [ansible-project] Creation date playbook with correct json query in yml file

2022-06-16 Thread Nipun Jain
Thank you so much Vladimir Botka.And it works now.
On Thursday, June 16, 2022 at 2:18:37 PM UTC+5:30 Nipun Jain wrote:

> Hi Dick,
> I understand your point ..I want to achieve the list of amis which is 
> based on creation date.For example i want to print out list of amis for 
> last 3 days and the output showing only 3 days before amis infoThats 
> the aim of above script.
> I hope you understand my problem situation.Imagine you have 100 amis so u 
> want to get info of particular date of amis like filters.
>
> On Thursday, June 16, 2022 at 12:41:25 PM UTC+5:30 dnmv...@gmail.com 
> wrote:
>
>> To start with You cannot use operators like > < etc on a string like 
>> '2022-06-10'.
>> Can you be more clear about what you want to achieve?
>>
>>
>> On Thu, 16 Jun 2022 at 06:19, Nipun Jain  wrote:
>>
>>> Hi Team,
>>> Looking forward to any input.
>>>
>>> *With Best Regards*
>>>
>>> Nipun Jain
>>>
>>>
>>> On Wed, Jun 15, 2022 at 2:40 PM Nipun Jain  wrote:
>>>
 Hi,
 I am trying to fetch the json data from ami info in the existing yml 
 using ansible.Now i am getting errors regarding json query format in 
 number 
 expression.
 I need help with proper json query under set fact so that the 
 indentation is maintained.Please suggest how this can be achieved.
 I am using below code for this :- 
 ---
 - name: List AMI info
   hosts: localhost
   gather_facts: yes
   tasks:
 - name: Gather AMI Info
   amazon.aws.ec2_ami_info:
 owners: self
 region: us-east-1
 filters:
   state: available
   register: result

 - name: Set fact date from last {{ec2_input_day}} days
   run_once: yes
   set_fact:
 ec2_f_date: "{{ lookup('pipe','date \"+%Y-%m-%d\" -d 
 \"{{ec2_input_day}} day ago\"') }}"
 - debug:
 var: ec2_f_date

 - name: Set fact date from {{ec2_input_day}} days using amis filters
   run_once: yes
   set_fact:
 ec2_f_amis: "{{ result | json_query(\"item[?creation_date<= \" 
 + ec2_f_date + \"]\") }}"
 - debug:
 var: ec2_f_amis
  
 PLease feel to run this script.Use this command => 

 ansible-playbook .yml -e ec2_input_day="'" 

 The output i am getting now is this :-
 fatal: [localhost]: FAILED! => {"msg": "JMESPathError in json_query 
 filter plugin:\ninvalid token: Parse error at column 22, token \"2022\" 
 (NUMBER), for expression:\n\"item[?creation_date<= 2022-06-10]\"\n 
   ^"}.

 Thank you.

  


 *Disclaimer: **© 2022 VVDN Technologies Pvt. Ltd. This e-mail contains 
 PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of the 
 addressee(s). If you are not the intended recipient, please notify the 
 sender by e-mail and delete the original message. Further, you are not to 
 copy, disclose, or distribute this e-mail or its contents to any other 
 person and any such actions are unlawful.*


 -- 
 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/aafeafa7-c036-48de-ab31-6fd88460afcen%40googlegroups.com
  
 
 .

>>>
>>>
>>> *Disclaimer: **© 2022 VVDN Technologies Pvt. Ltd. This e-mail contains 
>>> PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of the 
>>> addressee(s). If you are not the intended recipient, please notify the 
>>> sender by e-mail and delete the original message. Further, you are not to 
>>> copy, disclose, or distribute this e-mail or its contents to any other 
>>> person and any such actions are unlawful.*
>>>
>>>
>>> -- 
>>> 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/CAK1%2BVp%3DooLs5VpN4f9%2BgnfoRwwYrvhMr9ZHvQMbSLM670cdY0w%40mail.gmail.com
>>>  
>>> 
>>> .
>>>
>> -- 
>> Sent from Gmail Mobile
>>
>
-- 



_Disclaimer: _© 2022 VVDN Technologies Pvt. Ltd. This e-mail contains 
PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of the 
addressee(s). If you are not the intended recipient, please 

Re: [ansible-project] Creation date playbook with correct json query in yml file

2022-06-16 Thread Nipun Jain
Hi Dick,
I understand your point ..I want to achieve the list of amis which is based 
on creation date.For example i want to print out list of amis for last 3 
days and the output showing only 3 days before amis infoThats the aim 
of above script.
I hope you understand my problem situation.Imagine you have 100 amis so u 
want to get info of particular date of amis like filters.

On Thursday, June 16, 2022 at 12:41:25 PM UTC+5:30 dnmv...@gmail.com wrote:

> To start with You cannot use operators like > < etc on a string like 
> '2022-06-10'.
> Can you be more clear about what you want to achieve?
>
>
> On Thu, 16 Jun 2022 at 06:19, Nipun Jain  wrote:
>
>> Hi Team,
>> Looking forward to any input.
>>
>> *With Best Regards*
>>
>> Nipun Jain
>>
>>
>> On Wed, Jun 15, 2022 at 2:40 PM Nipun Jain  wrote:
>>
>>> Hi,
>>> I am trying to fetch the json data from ami info in the existing yml 
>>> using ansible.Now i am getting errors regarding json query format in number 
>>> expression.
>>> I need help with proper json query under set fact so that the 
>>> indentation is maintained.Please suggest how this can be achieved.
>>> I am using below code for this :- 
>>> ---
>>> - name: List AMI info
>>>   hosts: localhost
>>>   gather_facts: yes
>>>   tasks:
>>> - name: Gather AMI Info
>>>   amazon.aws.ec2_ami_info:
>>> owners: self
>>> region: us-east-1
>>> filters:
>>>   state: available
>>>   register: result
>>>
>>> - name: Set fact date from last {{ec2_input_day}} days
>>>   run_once: yes
>>>   set_fact:
>>> ec2_f_date: "{{ lookup('pipe','date \"+%Y-%m-%d\" -d 
>>> \"{{ec2_input_day}} day ago\"') }}"
>>> - debug:
>>> var: ec2_f_date
>>>
>>> - name: Set fact date from {{ec2_input_day}} days using amis filters
>>>   run_once: yes
>>>   set_fact:
>>> ec2_f_amis: "{{ result | json_query(\"item[?creation_date<= \" + 
>>> ec2_f_date + \"]\") }}"
>>> - debug:
>>> var: ec2_f_amis
>>>  
>>> PLease feel to run this script.Use this command => 
>>>
>>> ansible-playbook .yml -e ec2_input_day="'" 
>>>
>>> The output i am getting now is this :-
>>> fatal: [localhost]: FAILED! => {"msg": "JMESPathError in json_query 
>>> filter plugin:\ninvalid token: Parse error at column 22, token \"2022\" 
>>> (NUMBER), for expression:\n\"item[?creation_date<= 2022-06-10]\"\n 
>>>   ^"}.
>>>
>>> Thank you.
>>>
>>>  
>>>
>>>
>>> *Disclaimer: **© 2022 VVDN Technologies Pvt. Ltd. This e-mail contains 
>>> PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of the 
>>> addressee(s). If you are not the intended recipient, please notify the 
>>> sender by e-mail and delete the original message. Further, you are not to 
>>> copy, disclose, or distribute this e-mail or its contents to any other 
>>> person and any such actions are unlawful.*
>>>
>>>
>>> -- 
>>> 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/aafeafa7-c036-48de-ab31-6fd88460afcen%40googlegroups.com
>>>  
>>> 
>>> .
>>>
>>
>>
>> *Disclaimer: **© 2022 VVDN Technologies Pvt. Ltd. This e-mail contains 
>> PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of the 
>> addressee(s). If you are not the intended recipient, please notify the 
>> sender by e-mail and delete the original message. Further, you are not to 
>> copy, disclose, or distribute this e-mail or its contents to any other 
>> person and any such actions are unlawful.*
>>
>>
>> -- 
>> 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/CAK1%2BVp%3DooLs5VpN4f9%2BgnfoRwwYrvhMr9ZHvQMbSLM670cdY0w%40mail.gmail.com
>>  
>> 
>> .
>>
> -- 
> Sent from Gmail Mobile
>

-- 



_Disclaimer: _© 2022 VVDN Technologies Pvt. Ltd. This e-mail contains 
PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of the 
addressee(s). If you are not the intended recipient, please notify the 
sender by e-mail and delete the original message. Further, you are not to 
copy, disclose, or distribute this e-mail or its contents to any other 
person and any such actions are unlawful._
_
_
_
__

-- 
You received this message because you are 

Re: [ansible-project] Creation date playbook with correct json query in yml file

2022-06-16 Thread Vladimir Botka
On Wed, 15 Jun 2022 02:10:08 -0700 (PDT)
Nipun Jain  wrote:

> - name: Gather AMI Info
>   amazon.aws.ec2_ami_info:
> owners: self
> region: us-east-1
> filters:
>   state: available
>   register: result

Let's assume the data below for testing

result:
  images:
- name: app1
  creation_date: '2022-06-13T19:22:13.000Z'
- name: app2
  creation_date: '2022-06-14T19:22:13.000Z'
- name: app3
  creation_date: '2022-06-15T19:22:13.000Z'

> - name: Set fact date from last {{ec2_input_day}} days
>   run_once: yes
>   set_fact:
> ec2_f_date: "{{ lookup('pipe','date \"+%Y-%m-%d\"
> -d "{{ec2_input_day}} day ago\"') }}"

To get the current date use filter *strftime*, e.g.

ec2_f_date: "{{ '%Y-%m-%d %H:%M:%S'|strftime }}"

gives

ec2_f_date: '2022-06-16 10:29:58'

> 
> - name: Set fact date from {{ec2_input_day}} days using amis filters
>   run_once: yes
>   set_fact:
> ec2_f_amis: "{{ result | json_query(\"item[?creation_date<= \" + 
> ec2_f_date + \"]\") }}"
> - debug:
> var: ec2_f_amis

Use filter *to_datetime*. See "Handling dates and times"
https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html#handling-dates-and-times

Given 

ec2_input_day: '2'

In the loop, calculate the difference in days and evaluate the
condition, e.g.

- debug:
msg: "Age of {{ item.name }}
  is greater than or equal {{ ec2_input_day }} day(s)"
  loop: "{{ result.images }}"
  when: days|int >= ec2_input_day|int
  vars:
days: "{{ (ec2_f_date|to_datetime -
  item.creation_date|
  to_datetime('%Y-%m-%dT%H:%M:%S.000Z')).days }}"

will display the first image. The other two will be skipped

msg: Age of app1 is greater than or equal 2 day(s)

-- 
Vladimir Botka

-- 
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/20220616104704.017f3fa7%40gmail.com.


pgp_yapBPL88I.pgp
Description: OpenPGP digital signature


Re: [ansible-project] Creation date playbook with correct json query in yml file

2022-06-16 Thread Dick Visser
To start with You cannot use operators like > < etc on a string like
'2022-06-10'.
Can you be more clear about what you want to achieve?


On Thu, 16 Jun 2022 at 06:19, Nipun Jain  wrote:

> Hi Team,
> Looking forward to any input.
>
> *With Best Regards*
>
> Nipun Jain
>
>
> On Wed, Jun 15, 2022 at 2:40 PM Nipun Jain 
> wrote:
>
>> Hi,
>> I am trying to fetch the json data from ami info in the existing yml
>> using ansible.Now i am getting errors regarding json query format in number
>> expression.
>> I need help with proper json query under set fact so that the indentation
>> is maintained.Please suggest how this can be achieved.
>> I am using below code for this :-
>> ---
>> - name: List AMI info
>>   hosts: localhost
>>   gather_facts: yes
>>   tasks:
>> - name: Gather AMI Info
>>   amazon.aws.ec2_ami_info:
>> owners: self
>> region: us-east-1
>> filters:
>>   state: available
>>   register: result
>>
>> - name: Set fact date from last {{ec2_input_day}} days
>>   run_once: yes
>>   set_fact:
>> ec2_f_date: "{{ lookup('pipe','date \"+%Y-%m-%d\" -d
>> \"{{ec2_input_day}} day ago\"') }}"
>> - debug:
>> var: ec2_f_date
>>
>> - name: Set fact date from {{ec2_input_day}} days using amis filters
>>   run_once: yes
>>   set_fact:
>> ec2_f_amis: "{{ result | json_query(\"item[?creation_date<= \" +
>> ec2_f_date + \"]\") }}"
>> - debug:
>> var: ec2_f_amis
>>
>> PLease feel to run this script.Use this command =>
>>
>> ansible-playbook .yml -e ec2_input_day="'"
>>
>> The output i am getting now is this :-
>> fatal: [localhost]: FAILED! => {"msg": "JMESPathError in json_query
>> filter plugin:\ninvalid token: Parse error at column 22, token \"2022\"
>> (NUMBER), for expression:\n\"item[?creation_date<= 2022-06-10]\"\n
>>   ^"}.
>>
>> Thank you.
>>
>>
>>
>>
>> *Disclaimer: **© 2022 VVDN Technologies Pvt. Ltd. This e-mail contains
>> PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of the
>> addressee(s). If you are not the intended recipient, please notify the
>> sender by e-mail and delete the original message. Further, you are not to
>> copy, disclose, or distribute this e-mail or its contents to any other
>> person and any such actions are unlawful.*
>>
>>
>> --
>> 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/aafeafa7-c036-48de-ab31-6fd88460afcen%40googlegroups.com
>> 
>> .
>>
>
>
> *Disclaimer: **© 2022 VVDN Technologies Pvt. Ltd. This e-mail contains
> PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of the
> addressee(s). If you are not the intended recipient, please notify the
> sender by e-mail and delete the original message. Further, you are not to
> copy, disclose, or distribute this e-mail or its contents to any other
> person and any such actions are unlawful.*
>
>
> --
> 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/CAK1%2BVp%3DooLs5VpN4f9%2BgnfoRwwYrvhMr9ZHvQMbSLM670cdY0w%40mail.gmail.com
> 
> .
>
-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAF8BbLYJSuWjX8YG97Tc%2B5cfJa1O2SQ-F9gch71DUbRAY3dPLw%40mail.gmail.com.


Re: [ansible-project] ssh issue over non root account

2022-06-16 Thread Stefan Hornburg (Racke)

On 15/06/2022 17:58, Dick Visser wrote:

Your course should mention that SSH access is a requirement for the course :)
In any case as you pointed out it's not really an ansible specific problem but 
rather a generic system administration issue.
Read
https://docs.ansible.com/ansible/latest/user_guide/connection_details.html for 
some hints

Reg 'asap' - I wouldn't expect people to hurry because of poor planning and 
preparation on your side...


Yes, definitely agree with this.

@Orkhan you need to add the target user to your ssh command, e.g ssh 
@.

Regards

 Racke



On Wed, 15 Jun 2022 at 17:37, Orkhan Mammadov  wrote:

Hi guys,

I have issue with connecting over ssh to other machine using non root account. First of 
all, I create new fresh non root user. When I try to ssh , it gives 
permission denied message. Then I created key pairs using ssh-keygen and tried ssh-copy-id 
, it gives the same message. I added id_rsa.pub key tp authorized_keys 
file, however, the same issue. Could you please help to setup it asap, I can't start 
ansible course due to this issue.

Thanks in advance
-- 
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/7feb759c-807d-441a-9b4f-0a4448dcd14en%40googlegroups.com
 
.

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



--
Automation expert - Ansible and friends
Linux administrator & Debian maintainer
Perl Dancer & conference hopper

--
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/04ed6cb5-8e32-05d1-8d61-8e4496573b58%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature