Re: [ansible-project] Ansible 4.10.0 has been released

2021-12-15 Thread Nico Kadel-Garcia
On Tue, Dec 14, 2021 at 4:06 PM David Moreau Simard  wrote:
>
> Hi all,
>
> We're happy to announce that the ansible-4.10.0 package has been
> released to PyPi:
> https://pypi.org/project/ansible/4.10.0/
>
> This new version contains bug fixes as well as new, backwards
> compatible features in the Ansible collections that are included in
> the package.
> This is the last expected release for Ansible 4.x, read on for more 
> information.

I've updated my repo at https://github.com/nkadel/ansiblerepo/ to
include ansible-core-2.11.7 and ansible-4.10.0, built for RHEL 7 and
RHEL 8. I'm still tweaking the ansible-5.0.1 dependency to work with
ansible-core-2.11.7, so that this is available as well for RHEL 7 and
RHEL 8 as desired.

I've also tried again to register for EPEL based change requests to
integrate this support, but it's going to present issues in EPEL due
to the muc, much larger size of the new ansible tarballs.

-- 
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/CAOCN9rzf1%3DamVO5qS56Eje%2BRG-enGOwGYtqKzc8vP-ceeHrqtg%40mail.gmail.com.


Re: [ansible-project] Formatting date in Ansible

2021-12-15 Thread Vladimir Botka
On Thu, 16 Dec 2021 01:24:41 +0100
Vladimir Botka  wrote:

> On Wed, 15 Dec 2021 12:36:30 -0800 (PST)
> "lift...@gmail.com"  wrote:
> 
> > password expiration date/value is 20210715141027Z ... how to add 90 days to 
> > the expiration date.  
> 
> For example
> 
> - debug:
> var: _date90
>   vars:
> _date: "{{ pwdexp[0:4] }}-{{ pwdexp[4:6] }}-{{ pwdexp[6:8] }}"
> _sec: "{{ (_date|to_datetime('%Y-%m-%d')).strftime('%s')|int
>   + 90 * 24 * 60 * 60 }}"
> _date90: "{{ '%Y-%m-%d'|strftime(_sec) }}"
> 
> gives
> 
>   _date90: '2021-10-13'
> 

This can be simplified

_sec: "{{ (pwdexp[0:8]|
   to_datetime('%Y%m%d')).strftime('%s')|
   int + 90 * 24 * 60 * 60 }}"
_date90: "{{ '%Y-%m-%d'|strftime(_sec) }}"

-- 
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/20211216013723.6748d71f%40gmail.com.


pgpUsFnilWdeK.pgp
Description: OpenPGP digital signature


Re: [ansible-project] Formatting date in Ansible

2021-12-15 Thread Vladimir Botka
On Wed, 15 Dec 2021 12:36:30 -0800 (PST)
"lift...@gmail.com"  wrote:

> password expiration date/value is 20210715141027Z ... how to add 90 days to 
> the expiration date.

For example

- debug:
var: _date90
  vars:
_date: "{{ pwdexp[0:4] }}-{{ pwdexp[4:6] }}-{{ pwdexp[6:8] }}"
_sec: "{{ (_date|to_datetime('%Y-%m-%d')).strftime('%s')|int
  + 90 * 24 * 60 * 60 }}"
_date90: "{{ '%Y-%m-%d'|strftime(_sec) }}"

gives

  _date90: '2021-10-13'

-- 
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/20211216012441.55b78fc8%40gmail.com.


pgpq8pkIGR13o.pgp
Description: OpenPGP digital signature


[ansible-project] Re: Prevent single failure killing playbook

2021-12-15 Thread Omar
Hi,

I haven't tried it my self but I think max_fail_percentage 

 
is what you are looking for.


On Tuesday, December 14, 2021 at 7:47:50 PM UTC+3 thomasz...@gmail.com 
wrote:

> Hi All,
>
> I am currently running a playbook of several tasks, with serial:1 
> specified.
> If any of the tasks fail on host 1, I would like to still try them on host 
> 2 and host 3 etc. Perhaps host 1 is just too busy at the time to execute 
> the tasks, it seems annoying to have the whole playbook fail, particularly 
> if running it overnight.
>
> It feels there should be a way to accomplish this, any ideas?
>
> Thanks,
> Tom
>

-- 
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/bebf1b53-d606-4c2a-91ca-50d2bf2f6632n%40googlegroups.com.


[ansible-project] Infrastructure as Code - Manage Zabbix suggestions?

2021-12-15 Thread Lucas Possamai
Hi there.

I'm deploying a brand new Zabbix cluster and wanted to do it the "right"
way. I thought I would use Ansible to manage Zabbix, add hosts, add Media
Types, Actions, etc, but the Ansible Zabbix Collection

is not well documented and it doesn't work properly.

Do you guys have any suggestions on which tool to use to manage Zabbix? My
goal is to run one command and get a new host added, or a new media type,
or a new zabbix action setup.

Thanks!
Lucas

-- 
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/CAE_gQfWLBwMTHK88PYEx20HZY7oLfsphXd4%2BEnHyQcmWdq8Opg%40mail.gmail.com.


[ansible-project] Formatting date in Ansible

2021-12-15 Thread lift...@gmail.com
In another thread, I was explaining how I'm getting a user's information 
from our IPA server.  I believe that the password expiration is already in 
a datetime format.  I'd like to display it to the user via email in a more 
standard format.

For example, let's say that the user's password expiration date/value is 
20210715141027Z.  In the email I send out to them, I'd like to show 
07/15/2021.  Then, I'd like to calculate the date where their account will 
be automatically disabled, which should be 90 days after the expiration 
date.  But I can't figure out how to add 90 days to the expiration date.

Here's part of my playbook for reference:

  - name: Set Disabled Users fact
set_fact:
  disabled_users: "{{ user_show.results | 
json_query('[*].json.result.result.{uid: uid[0], mail: mail[0], 
nsaccountlock: nsaccountlock, pwdexp: 
krbpasswordexpiration[0].__datetime__}') | 
selectattr('pwdexp','<',cutoff_date) | selectattr('nsaccountlock', 
'equalto', False) | list }}"

  - name: Print disabled users
debug:
  msg: "{{ item.uid }} / {{ item.mail }} / {{ 
item.pwdexp.format('%m/%d/%Y') }}"
loop: "{{ disabled_users }}"

Thanks,
Harry

-- 
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/abf9d827-3130-4154-b761-f36032f6cf68n%40googlegroups.com.


[ansible-project] Implementar Firewall en ansible

2021-12-15 Thread Liliana Achig
Por favor me pueden ayudar, tengo que desplegar un firewall en ansible 
mediante un playbooks, he intentado con algunas plantillas pero me sale 
como que no tuviera conexión entre la maquina central y el nodo host. Por 
favor alguna solución o comentario acerca de esto 

-- 
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/ce0a11bc-e54f-4ea5-82e0-ea14aab71b82n%40googlegroups.com.


Re: [ansible-project] How do I correctly pass NULL in set_fact ?

2021-12-15 Thread Stefan Hornburg (Racke)

On 15/12/2021 13:40, Anthony Palermo wrote:

I am not able to pass a NULL to community.mysql.mysql_query but I think the 
issue is independent from the module

https://gist.github.com/aworldofcode/35de280946fabcc66e2eea15c8a13dd8


# mariadb sql table includes the following column
`date_of_removal` datetime DEFAULT NULL,


# The Key Dict is either
'main_dict.removal_info is defined': '2021-12-19 21:50:43' # a datetime 
properly formated
'main_dict.removal_info is defined': 'N/A' # A string

# The goal is to properly provide a Null when 'N/A' is present

# Meanwhile in Ansible set_fact

- name: Set the etl_dictionary Key Value Dictionary from main_dict request
set_fact:
etl_dictionary: >-
{

{% if main_dict.removal_info is defined -%}
{% if 'N/A' in main_dict.removal_info -%}
"date_of_removal": 'Null' ,
{% else %}
"date_of_removal": "{{main_dict.removal_info}}",
{% endif %}
{% endif %}

}

# SQL Statement
# Cannot execute SQL 'INSERT INTO  'N/A', 'No', 'null', 'N/A' The expected 
behaviour to achieve is ... 'N/A', 'No', Null, 'N/A'


how would I pass correctly null in a set_fact ?


I think that the Python keyword None (without quotes around) is the equivalent 
of a null value and should translate to NULL in the SQL world.
Not tested though.

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-project+unsubscr...@googlegroups.com 
.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/55e0f1ca-b655-432c-917a-7e8d40912cb2n%40googlegroups.com
 
.



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


--
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/5b7d2483-1a93-4931-c7ab-c7cb2c85b121%40linuxia.de.


OpenPGP_signature
Description: OpenPGP digital signature


[ansible-project] Re: How to make ansible ignore a group name in hosts file if it has no ip?

2021-12-15 Thread Vikram S
Hi,

I am the OP and i just got an idea for my above question. Do you think 
below script might solve my issue?


   - 
   
   name: PLAYBOOK FOR STANDBY FIREWALL UPGRADE
   
   hosts: STANDBYFIREWALL
   
   serial: 1
   
   gather_facts: false
   
   connection: network_cli
   
   tasks:
   - 
  
  name: End playbook if connection IP is not defined
  
  meta: end_host
  
  when: {{ ansible_host }} is not defined
  
Thanks,
Vikram


On Wednesday, 15 December, 2021 at 9:45:07 pm UTC+5:30 Vikram S wrote:

> I have 2 groups created in hosts file as given below. I have a playbook 
> consisting of 2 plays - the 1st play will be executed on IP in 
> 'ACTIVEFIREWALL' group and 2nd play will be executed on IP in 
> 'STANDBYFIREWALL' group.
>
> Many a times, i have no ip to be give for 'STANDBYFIREWALL' group (so the 
> ip portion remains blank but everything else mentioned below remains on 
> hosts file). So the 2nd play just stops and does nothing until timeout. 
> However when i delete the entire 'STANDBYFIREWALL' group from inventory 
> file, Ansible ignores the 2nd play containing 'STANDBYFIREWALL' group and 
> moves on.
>
>
> Is there any ways i can make Ansible to move on without deleting 
> STANDBYFIREWALL group from hosts file when there is no IP to give?
>
>
> [ACTIVEFIREWALL]
>
> FW1 ansible_host=10.224.240.241
>
>
> [ACTIVEFIREWALL:vars]
>
> ansible_user=username
>
> ansible_ssh_pass=password
>
>
> [STANDBYFIREWALL]
>
> FW2 ansible_host=10.224.240.244
>
>
> [STANDBYFIREWALL:vars]
>
> ansible_user=username
>
> ansible_ssh_pass=password
>
>
> Thanks,
>
> Vikram
>

-- 
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/6ec58f94-29b5-4016-bc04-fd659dcf089bn%40googlegroups.com.


[ansible-project] How to make ansible ignore a group name in hosts file if it has no ip?

2021-12-15 Thread Vikram S


I have 2 groups created in hosts file as given below. I have a playbook 
consisting of 2 plays - the 1st play will be executed on IP in 
'ACTIVEFIREWALL' group and 2nd play will be executed on IP in 
'STANDBYFIREWALL' group.

Many a times, i have no ip to be give for 'STANDBYFIREWALL' group (so the 
ip portion remains blank but everything else mentioned below remains on 
hosts file). So the 2nd play just stops and does nothing until timeout. 
However when i delete the entire 'STANDBYFIREWALL' group from inventory 
file, Ansible ignores the 2nd play containing 'STANDBYFIREWALL' group and 
moves on.


Is there any ways i can make Ansible to move on without deleting 
STANDBYFIREWALL group from hosts file when there is no IP to give?


[ACTIVEFIREWALL]

FW1 ansible_host=10.224.240.241


[ACTIVEFIREWALL:vars]

ansible_user=username

ansible_ssh_pass=password


[STANDBYFIREWALL]

FW2 ansible_host=10.224.240.244


[STANDBYFIREWALL:vars]

ansible_user=username

ansible_ssh_pass=password


Thanks,

Vikram

-- 
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/09dcd376-7d03-44e3-933d-a36c4bb8ae9bn%40googlegroups.com.


[ansible-project] How do I correctly pass NULL in set_fact ?

2021-12-15 Thread Anthony Palermo
I am not able to pass a NULL to community.mysql.mysql_query but I think the 
issue is independent from the module

https://gist.github.com/aworldofcode/35de280946fabcc66e2eea15c8a13dd8


# mariadb sql table includes the following column 
`date_of_removal` datetime DEFAULT NULL, 


# The Key Dict is either 
'main_dict.removal_info is defined': '2021-12-19 21:50:43' # a datetime 
properly formated 
'main_dict.removal_info is defined': 'N/A' # A string 

# The goal is to properly provide a Null when 'N/A' is present 

# Meanwhile in Ansible set_fact 

- name: Set the etl_dictionary Key Value Dictionary from main_dict request 
set_fact: 
etl_dictionary: >- 
{ 

{% if main_dict.removal_info is defined -%} 
{% if 'N/A' in main_dict.removal_info -%} 
"date_of_removal": 'Null' , 
{% else %} 
"date_of_removal": "{{main_dict.removal_info}}", 
{% endif %} 
{% endif %} 

} 

# SQL Statement 
# Cannot execute SQL 'INSERT INTO  'N/A', 'No', 'null', 'N/A' The 
expected behaviour to achieve is ... 'N/A', 'No', Null, 'N/A'


how would I pass correctly null in a set_fact ?

-- 
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/55e0f1ca-b655-432c-917a-7e8d40912cb2n%40googlegroups.com.


[ansible-project] Re: Problem with delegate_to to group in inventory

2021-12-15 Thread Todd Lewis
BTW, your initial problem was that you had
delegate_to: zabbixprimary
where you needed
delegate_to: "{{ zabbixprimary }}"
But you're well past that now.

As my old CompSci prof. used to say, "*Don't let these little things 
confuse you. Try to get confused on a higher level.*"
On Tuesday, December 14, 2021 at 9:37:00 PM UTC-5 drum@gmail.com wrote:

> Hi guys.
>
> I'm trying to use the "delegate_to", to only run a certain task to a group 
> in my inventory.
>
> inventory file:
> [zabbixprimary]
> localhost ansible_port=2235 # zabbix primary
>
> [zabbixslave]
> localhost ansible_port=2236 # zabbix secondary
>
> [zabbix:children]
> zabbixprimary
> zabbixslave
>
> main.yml:
> - name: Setup Zabbix and Grafana
> hosts: zabbix
> become: yes
> become_user: root
> gather_facts: False
>
> task.yml:
> - name: Enable Zabbix HA - primary
> run_once: true
> ansible.builtin.shell: sed -i 's/# HANodeName=/HANodeName={{ 
> hostname_secondary }}/g' /etc/zabbix/zabbix_server.conf && sed -i 's/# 
> NodeAddress=localhost:10051/NodeAddress={{ hostname_primary }}:10051/g' 
> /etc/zabbix/zabbix_server.conf
> when: not ansible_check_mode and zabbix_ha
> delegate_to: zabbixprimary
>
> - name: Enable Zabbix HA - secondary
> run_once: true
> ansible.builtin.shell: sed -i 's/# 
> NodeAddress=localhost:10051/NodeAddress={{ hostname_secondary }}:10051/g' 
> /etc/zabbix/zabbix_server.conf
> when: not ansible_check_mode and zabbix_ha
> delegate_to: zabbixslave
>
> But I get an error:
> fatal: [localhost -> zabbixprimary]: UNREACHABLE! => {"changed": false, 
> "msg": "Failed to connect to the host via ssh: ssh: Could not resolve 
> hostname zabbixprimary: nodename nor servname provided, or not known", 
> "unreachable": true}
>
> Am i doing it right? I couldn't find much information online about how to 
> achieve this.
>
> Thanks!
> Lucas
>

-- 
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/fa49dad3-1ce5-491c-80f1-012ac6bd3546n%40googlegroups.com.


Re: [ansible-project] Re: Problem with delegate_to to group in inventory

2021-12-15 Thread Vasily Klimov
[zabbix]
zabbixprimary  ansible_host=IP_ADDRESS ansible_port=PORT
zabbixslave  ansible_host=IP_ADDRESS ansible_port=PORT


[zabbix:vars]
ansible_python_interpreter=/usr/bin/python3
ansible_user=login
ansible_password=password

Good luck.

среда, 15 декабря 2021 г. в 09:06:17 UTC+3, drum@gmail.com: 

> On Wed, 15 Dec 2021 at 19:00, Lucas Possamai  wrote:
>
>> On Wed, 15 Dec 2021 at 18:44, Vladimir Botka  wrote:
>>
>>> It's not possible to delegate a task to a group. Delegate to a host
>>> instead. Change the inventory. For example
>>>
>>>   shell> cat hosts
>>>   zabbixprimary ansible_host=localhost ansible_port=2235
>>>   zabbixslave ansible_host=localhost ansible_port=2236
>>>
>>>   [zabbix]
>>>   zabbixprimary
>>>   zabbixslave
>>>
>>> You should be able to delegate to the hosts. For example
>>>
>>>   - hosts: zabbix
>>> tasks:
>>>   - shell: echo OK
>>> delegate_to: zabbixprimary
>>> run_once: true
>>>   - shell: echo OK
>>> delegate_to: zabbixslave
>>> run_once: true
>>>
>>> should work as expected
>>>
>>>   TASK [shell] *
>>>   changed: [zabbixprimary -> zabbixprimary]
>>>
>>>   TASK [shell] *
>>>   changed: [zabbixprimary -> zabbixslave]
>>>
>>> -- 
>>> Vladimir Botka
>>>
>>
>> Interesting! And can I use the "delegate_to" command to more than one 
>> host at a time?
>>
>>
> Yes, I can! Using:
>
> delegate_to: "{{ item }}"
> delegate_facts: true
> loop:
> - zabbixslave
> - zabbixslave02
>  
>
>> Cheers!
>> Lucas 
>>
>

-- 
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/0ab6d77d-e90e-42d1-8fcb-6de845aab13en%40googlegroups.com.