Re: [ansible-project] Re: Ansible variable data to CSV file

2023-03-07 Thread Aharonu
*Thank you Todd for your time and help.*

Hi All,

I have tested in my environment. It is working good.

i have one item to update for conditions. Could anyone please do me a favor
. Thank you

[ how to add one condition like vol_name != '_test' or vol_name !='Test*' ] (
this way working in Python looking help of playbook as i tried and not
working)
- name: Copy csv where status == 'online' and work_status == 'not_used'
  ansible.builtin.copy:
content: |
  cluster_name,log_cluster,vol_name,status,work_status
  {% for line in csv %}
  {% set (cluster_name,log_cluster,vol_name,status,work_status)
= line.split(',', maxsplit=4) %}
  {% if status == 'online' and work_status == 'not_used'  %}
  {{ line }}
  {% endif %}
  {% endfor %}
dest: aharonu-online-not_used.csv
[ How dow we include instead of endswith('Test'), i have to include like
vol_name contains 'Test', 'test'..etc]
- name: Copy csv where status == 'offline' and vol_name.endswith('Test')
  # Note: there are none of these in the test data.
  ansible.builtin.copy:
content: |
  cluster_name,log_cluster,vol_name,status,work_status
  {% for line in csv %}
  {% set (cluster_name,log_cluster,vol_name,status,work_status)
= line.split(',', maxsplit=4) %}
  {% if status == 'offline' or status == 'online' and
vol_name.endswith('Test') %}
  {{ line }}
  {% endif %}
  {% endfor %}
dest: aharonu-offline-test.csv
- name: Copy csv where status == 'online' and work_status == 'used'
  ansible.builtin.copy:
content: |
  cluster_name,log_cluster,vol_name,status,work_status
  {% for line in csv %}
  {% set (cluster_name,log_cluster,vol_name,status,work_status)
= line.split(',', maxsplit=4) %}
  {% if status == 'online' and work_status == 'used' %}
  {{ line }}
  {% endif %}
  {% endfor %}
dest: aharonu-online-used.csv





On Tue, 7 Mar 2023, 09:36 Todd Lewis,  wrote:

> ---
> - name: Creating CSVs from subsets of data
>   hosts: localhost
>   gather_facts: false
>   vars:
> csv:
>   - cluster1,virtual_clu1,log_vol1,online,used
>   - cluster1,virtual_clu1,log_vol2,offline,not_used
>   - cluster1,virtual_clu1,log_vol3_Test,online,not_used
>   - cluster1,virtual_clu1,log_vol4,offline,not_used
>   - cluster2,virtual_clu2,log_vol6,online,used
>   - cluster2,virtual_clu2,log_vol1,offline,not_used
>   - cluster2,virtual_clu2,log_vol3,online,not_used
>   - cluster2,virtual_clu2,log_vol4,online,used
>   tasks:
>
> - name: Copy csv where status == 'online' and work_status == 'not_used'
>   ansible.builtin.copy:
> content: |
>   cluster_name,log_cluster,vol_name,status,work_status
>   {% for line in csv %}
>   {% set (cluster_name,log_cluster,vol_name,status,work_status) = 
> line.split(',', maxsplit=4) %}
>   {% if status == 'online' and work_status == 'not_used' %}
>   {{ line }}
>   {% endif %}
>   {% endfor %}
> dest: aharonu-online-not_used.csv
>
> - name: Copy csv where status == 'offline' and vol_name.endswith('Test')
>   # Note: there are none of these in the test data.
>   ansible.builtin.copy:
> content: |
>   cluster_name,log_cluster,vol_name,status,work_status
>   {% for line in csv %}
>   {% set (cluster_name,log_cluster,vol_name,status,work_status) = 
> line.split(',', maxsplit=4) %}
>   {% if status == 'offline' and vol_name.endswith('Test') %}
>   {{ line }}
>   {% endif %}
>   {% endfor %}
> dest: aharonu-offline-test.csv
>
> - name: Copy csv where status == 'online' and work_status == 'used'
>   ansible.builtin.copy:
> content: |
>   cluster_name,log_cluster,vol_name,status,work_status
>   {% for line in csv %}
>   {% set (cluster_name,log_cluster,vol_name,status,work_status) = 
> line.split(',', maxsplit=4) %}
>   {% if status == 'online' and work_status == 'used' %}
>   {{ line }}
>   {% endif %}
>   {% endfor %}
> dest: aharonu-online-used.csv
>
> Save the above as aharonu-csv.yml and run as
>
> ansible-playbook aharonu-csv.yml -vv && grep , ./aharonu*.csv
>
>
> On 3/6/23 2:58 PM, Aharonu wrote:
>
> Thanks Walter.
>
> May I still ask a favor for CVS data structure atleast for any of one
> condion here so I can refer and work on remaining? Once I got flow it helps
> to explore more. Thanking you.
>
> The header must be:  cluster_name,log_cluster,vol_name,status,work_status
>
> not working:
> (it has to give here when status=online and  work_status=not_used )
> exclude:
> (it has go give here when status=offline and  vol_name= 'Test'>)
> working:
> (it has to give here when 

[ansible-project] help configuring aap centrify vault credential provider lookup

2023-03-07 Thread cary.c...@gmail.com
I am attempting to run playbooks from aap that will checkout credentials 
from our Centrify solution.  Has anyone gotten this working?  My attempts 
to configure the centrify vault credential provider lookup fails the test 
connection.

The credential I am attempting to "check out" is an AD user account managed 
by Centrify, but it does not have any "systems" which I interpret as 
"windows servers" associated with it.

I have reviewed the documentation on the Centrify site and the Red Hat 
Site, but I'm unable to get it working.

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/832e45f8-4988-4b97-b17c-a973c3dd509fn%40googlegroups.com.


Re: [ansible-project] Re: Based on Variable defined template should behave

2023-03-07 Thread Prady A
Hi Lewis

Your advice worked like a charm. Thank u again . I replaced this piece of
code with yours.

{% if variable is defined %}
value of variable: {{ variable }}
{% else %}
variable is not defined
{% endif %}

But can we extend you piece of code to take the default value except for
Amazon servers.
Amazon servers = ansible_local.bu
!Amazon servers = ansible_local.lob

Regards
PD

On Mon, Mar 6, 2023 at 21:40, Todd Lewis  wrote:

> *Template: *etc-motd.j1
> REMINDER: This is {{ ansible_hostname }}, a {{ ansible_local.function }}
> server of {{ ansible_local.project }}, owned by {{ ansible_local.lob |
> default(ansible_local.bu) }}
>
>
> On Monday, March 6, 2023 at 2:29:18 AM UTC-5 Prady A wrote:
>
>> Hello experts,
>>
>> Need one little suggestion on below ..
>> Below is my current code .
>>
>> - name: set /etc/motd for abcd servers
>>   template:
>> src: etc-motd.j1
>> dest: /etc/motd
>> owner: root
>> group: root
>> mode: 0644
>> backup: yes
>>   when:
>>- is_us
>>
>> *Template: *etc-motd.j1
>> REMINDER: This is {{ ansible_hostname }}, a {{ ansible_local.function }}
>> server of {{ ansible_local.project }}, owned by {{ ansible_local.*bu* }}
>>
>> Now the problem is when ansible_local.*lob is *defined then the above
>> ansible_local.*bu* should be replaced by ansible_local.*lob* but if not
>> defined then it should use ansible_local.*bu. *
>>
>> I know if I write two templates one is for *bu* and one is for *lob* the
>> it might solve.  Like below . But it will too much change for this
>> requirement I guess . Any better idea will be appreciated.
>>
>> *- *name: set /etc/motd for abcd servers
>>   template:
>> src: etc-motd.j1
>> dest: /etc/motd
>> owner: root
>> group: root
>> mode: 0644
>> backup: yes
>>   when:
>>- is_us
>>- ansible_local.*lob* is *defined*
>>
>> *template1*: etc-motd.j1
>> REMINDER: This is {{ ansible_hostname }}, a {{ ansible_local.function }}
>> server of {{ ansible_local.project }}, owned by {{ ansible_local.*lob* }}
>>
>>
>> ===
>> - name: set /etc/motd for abcd servers
>>   template:
>> src: etc-motd.j2
>> dest: /etc/motd
>> owner: root
>> group: root
>> mode: 0644
>> backup: yes
>>   when:
>>- is_us
>>- ansible_local.*lob is not *defined
>>
>> *Template*: etc-motd.j2
>> REMINDER: This is {{ ansible_hostname }}, a {{ ansible_local.function }}
>> server of {{ ansible_local.project }}, owned by {{ ansible_local.*bu* }}
>>
>> 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/f0b3e3b0-89c7-4033-b07d-14243352ffd1n%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/CAEuB3Ap4F0CW6qZxTvEnjmsphawgn-V5-MUTa2vzTUARhr4Chg%40mail.gmail.com.


Re: [ansible-project] Could not install pfsense-core

2023-03-07 Thread Ala Karmous
okay thank you, it was resolved 

Le mardi 7 mars 2023 à 12:20:32 UTC+1, dulh...@mailbox.org a écrit :

> I think you can make a lot more friends (an likewise receive more, better 
> feedback) by posting error messages as text instead of images.
>
> In regards to your question ... I don't know, but it could be an idea to 
> either check the index site for ansible modules 
> https://docs.ansible.com/ansible/latest/collections/index_module.html, or 
> search for the repository of the mentioned pfsense-core module for 
> information on how to install, or maintenance status.
>
>
>
>  
> On 07.03.23 09:39, Ala Karmous wrote:
>
> there is the error when i try to install pfsense-core, maybe the 
> 'pfsense-core' module is no longer available via 'pip'.  
> if someone knows how to fix it please let me know.
> [image: error.PNG]
>
> -- 
> 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/76d25552-068c-430d-a63c-3950ea06dfb8n%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/42ab1410-feb7-4684-9a82-d3f964a3f704n%40googlegroups.com.


Re: [ansible-project] Ansible variable data to CSV file

2023-03-07 Thread Vladimir Botka
On Mon, 6 Mar 2023 19:09:21 +
Aharonu  wrote:

> "csv": [
> "cluster1,virtual_clu1,log_vol1,online,used",
> "cluster1,virtual_clu1,log_vol2,offline,not_used",
> "cluster1,virtual_clu1,log_vol3_Test,online,not_used",
> "cluster1,virtual_clu1,log_vol4,offline,not_used",
> "cluster2,virtual_clu2,log_vol6,online,used",
> "cluster2,virtual_clu2,log_vol1,offline,not_used",
> "cluster2,virtual_clu2,log_vol3,online,not_used"
> "cluster2,virtual_clu2,log_vol4,online,used"
> ]
> 
> *Looking for:*
> The header must be:  cluster_name,log_cluster,vol_name,status,work_status
> 
> not working:
> (it has to give here when status=online and  work_status=not_used )
> exclude:
> (it has go give here when status=offline and  vol_name= 'Test'>)  
> working:
> (it has to give here when status=online and work_status=used
> [other then not working & exclude list] )
> 
> *example: file1.csv*
> 
> not working:
> cluster_name,log_cluster,vol_name,status,work_status
> cluster2,virtual_clu2,log_vol3,online,not_used
> 
> exclude:
> cluster_name,log_cluster,vol_name,status,work_status
> cluster1,virtual_clu1,log_vol3_Test,online,not_used
> cluster1,virtual_clu1,log_vol2,offline,not_used
> cluster1,virtual_clu1,log_vol4,offline,not_used
> cluster2,virtual_clu2,log_vol1,offline,not_used
> 
> working:
> cluster_name,log_cluster,vol_name,status,work_status
> cluster1,virtual_clu1,log_vol1,online,used
> cluster2,virtual_clu2,log_vol6,online,used
> cluster2,virtual_clu2,log_vol4,online,used

Put the header into the list

  header: [cluster_name, log_cluster, vol_name, status, work_status]

and use the filter *community.general.dict* to create the dictionary

  csv_dict: "{{ csv|
map('split', ',')|
map('zip', header)|
map('map', 'reverse')|
map('community.general.dict') }}"

gives

  csv_dict:
  - cluster_name: cluster1
log_cluster: virtual_clu1
status: online
vol_name: log_vol1
work_status: used
  - cluster_name: cluster1
...

Select the subsets

  notworking: "{{ csv_dict|
  selectattr('status', '==', 'online')|
  selectattr('work_status', '==', 'not_used') }}"
  exclude: "{{ csv_dict|
   selectattr('status', '==', 'offline')|
   selectattr('vol_name', 'regex', '^log_vol[1-4]$') }}"
  working: "{{ csv_dict|
   selectattr('status', '==', 'online')|
   difference(notworking)|
   difference(exclude) }}"

and write them to the files. Test it first

- debug:
msg: |
  dest: {{ item.1 }}
  {{ item.0 }}:
  {{ header|join(',') }}
  {% for l in lookup('vars', item.0) %}
  {{ l.values()|join(',') }}
  {% endfor %}
  loop:
- [notworking, fiel1.csv]
- [exclude, fiel2.csv]
- [working, fiel3.csv]

gives (abridged)

  msg: |-
dest: fiel1.csv
notworking:
cluster_name,log_cluster,vol_name,status,work_status
cluster1,virtual_clu1,log_vol3_Test,online,not_used
cluster2,virtual_clu2,log_vol3,online,not_used

  msg: |-
dest: fiel2.csv
exclude:
cluster_name,log_cluster,vol_name,status,work_status
cluster1,virtual_clu1,log_vol2,offline,not_used
cluster1,virtual_clu1,log_vol4,offline,not_used
cluster2,virtual_clu2,log_vol1,offline,not_used

  msg: |-
dest: fiel3.csv
working:
cluster_name,log_cluster,vol_name,status,work_status
cluster1,virtual_clu1,log_vol1,online,used
cluster2,virtual_clu2,log_vol6,online,used
cluster2,virtual_clu2,log_vol4,online,used


Notes:

* There are two items in *notworking* not only one

* The line where vol_name='log_vol3_Test' shouldn't be in the set
  *exclude* because of the condition status=='offline'. Fit the regex
  to your needs.

  cluster1,virtual_clu1,log_vol3_Test,online,not_used


-- 
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/20230307101422.2ce5d380%40gmail.com.


pgpuWsCqpWct5.pgp
Description: OpenPGP digital signature


[ansible-project] Could not install pfsense-core

2023-03-07 Thread Ala Karmous
there is the error when i try to install pfsense-core, maybe the 
'pfsense-core' module is no longer available via 'pip'. 
if someone knows how to fix it please let me know.
[image: error.PNG]

-- 
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/76d25552-068c-430d-a63c-3950ea06dfb8n%40googlegroups.com.