Re: [ansible-project] what determines which version of ansible is invoked when running ansible

2023-08-09 Thread Will McDonald
It'll be whichever installed ansible is first in your PATH and is
executable.

Here's a simple example:

$ echo $PATH
/usr/local/bin:/usr/bin

$ ll /usr/local/bin/wtf /usr/bin/wtf
-rwxr-xr-x 1 root root 35 Aug  9 23:48 /usr/bin/wtf*
-rwxr-xr-x 1 root root 41 Aug  9 23:48 /usr/local/bin/wtf*

$ cat /usr/local/bin/wtf /usr/bin/wtf
#!/bin/sh
echo We are in: /usr/local/bin
$ cat /usr/bin/wtf
#!/bin/sh
echo We are in: /usr/bin

$ wtf
We are in: /usr/local/bin

Swap the order in the PATH:

$ export PATH=/usr/bin:/usr/local/bin
$ wtf
We are in: /usr/bin

Make the closest script non-executable:

$ sudo chmod -x /usr/bin/wtf
$ wtf
We are in: /usr/local/bin

If you're pip-installing things ideally you want to do that in a Python
virtual environment (venv) so you don't trample over system Python modules.
Bonus of using venv is then when you toggle that venv 'on' the version
executed is largely taken care of for you.

See https://www.redhat.com/sysadmin/python-venv-ansible,
https://www.cbtnuggets.com/blog/technology/devops/how-to-install-ansible-in-a-python-virtual-environment
or many of the other how-tos for references.


On Wed, 9 Aug 2023 at 23:16, dmastrop  wrote:

> hi
>
> I have 2 versions of ansible installed on my Mac.(it was not intentional)
>
> One version was not installed through pip and the other version was
> installed through pip.
>
> I had to manually fix some permissions issues and now that those are
> addressed my terminal (VSCode) invokes the older version rather than the
> newer version.
>
> *What determines which version is run when there are multiple versions on
> a computer?*
> (from what I have read, pip does not install an ansible.cfg file and I
> don't know if that is where the setting is)
>
>
> I thought it might be the $PATH in the terminal but the path includes both
> versions.
>
>
> this is the version ansible 3.7.9(core 2.11.12). This was not installed
> through pip
>
>
>  % ansible --version
>
> [DEPRECATION WARNING]: Ansible will require Python 3.8 or newer on the
> controller starting with Ansible 2.12. Current
>
> *version: 3.7.9 *(v3.7.9:13c94747c7, Aug 15 2020, 01:31:08) [Clang 6.0
> (clang-600.0.57)]. This feature will be removed
>
> from ansible-core in version 2.12. Deprecation warnings can be disabled by
> setting deprecation_warnings=False in
>
> ansible.cfg.
>
> *ansible [core 2.11.12] *
>
>   config file = None
>
>   configured module search path =
> ['/Users/davemastropolo/.ansible/plugins/modules',
> '/usr/share/ansible/plugins/modules']
>
>   ansible python module location =
> /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ansible
>
>   ansible collection location =
> /Users/davemastropolo/.ansible/collections:/usr/share/ansible/collections
>
>   executable location =
> /Library/Frameworks/Python.framework/Versions/3.7/bin//ansible
>
>   python version = 3.7.9 (v3.7.9:13c94747c7, Aug 15 2020, 01:31:08) [Clang
> 6.0 (clang-600.0.57)]
>
>   jinja version = 3.1.2
>
>   libyaml = True
>
>
>
>
> this (below) is the newer version installed through pip:
>
> this *was* invoked through the terminal prior to fixing the permission
> issue on one of the directories (it was invoked but failing  due to the
> permission issue)
>
>
> Once the permission issue was addressed, ansible now invokes the older
> version (above)
>
>
>
>  % python3 -m pip list
> Package  Version
>  
>
> *ansible  8.2.0ansible-core 2.15.2*
> certifi  2023.5.7
> cffi 1.15.1
> cryptography 41.0.3
> Jinja2   3.1.2
> MarkupSafe   2.1.3
> packaging23.1
> pip  23.1.2
> pycparser2.21
> PyYAML   6.0.1
> resolvelib   1.0.1
> setuptools   65.5.0
>
>
>
> warm regards
>
> Dave
>
>
> --
> 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/158f2e5f-0a55-4a18-98e5-cbadde94a98fn%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/CAKtKohQnznVbABiLsq4Qsco%2BfyRUEyb9Cvf_X7qahy7iOEoB_Q%40mail.gmail.com.


Re: [ansible-project] yum/dnf/package modules hanging on whole system update

2023-08-09 Thread Evan Hisey
Good catch on the jumphost Will. If that is timing out mid patch cycle due
to duration of yum upgrade job you would get this behavior.

On Wed, Aug 9, 2023, 5:40 PM Will McDonald  wrote:

> Looking at your verbose output, it looks like your ansible runs are
> tunneled through a bastion/jumphost/proxy?
>
> When you run your "yum update" directly on a host, are you doing:
>
> [user@*control-node* ~]$ ssh user@target
> [user@*target-node* ~] sudo yum -y update
>
> Or are you doing:
>
> [user@*control-node* ~]$ ssh user@*target-node* sudo yum -y update
>
> I'm just wondering if there's something unusual in the bastion connection
> handling, or the shell environment of a full interactive shell with a TTY
> vs. an ansible run?
>
> Similarly, you have your -vvv output of a *failing *run. If you do -vvv
> for a *working *run, does that cast any light, indicate any differences
> in behaviour in connection, privilege escalation or command invocation?
>
> Do you have any proxies defined that may be being picked up from the
> environment in an interactive session which aren't in an ansible run?
>
>
> On Wed, 9 Aug 2023 at 23:15, Nicolas Goudry  wrote:
>
>> Thanks for stepping in to help.
>>
>> I did run sudo yum update -y directly in one of my hosts, and everything
>> went well.
>>
>> Also, I created the following playbook and surprisingly it works:
>>
>> - hosts: all
>> gather_facts: no
>> tasks:
>> - name: YUM | Get available package updates
>> yum:
>> list: updates
>> register: yum_available_package_updates
>> - name: YUM | Update packages
>> yum:
>> name: "{{ yum_available_package_updates.results | map(attribute='name')
>> | list }}"
>> state: 'latest'
>> register: yum_upgrade
>> - name: YUM | Reboot after packages updates
>> when:
>> - yum_upgrade.changed
>> reboot:
>>
>> However, if I use it as an ansible role, like so:
>>
>> ---
>> - name: YUM | Get available package updates
>> yum:
>> list: updates
>> register: yum_available_package_updates
>> - name: YUM | Update packages
>> yum:
>> name: "{{ yum_available_package_updates.results | map(attribute='name')
>> | list }}"
>> state: 'latest'
>> register: yum_upgrade
>> - name: YUM | Reboot after packages updates
>> when:
>> - yum_upgrade.changed or system_upgrade_reboot == 'always'
>> - system_upgrade_reboot != 'never'
>> reboot:
>>
>> It doesn’t work (well, the system does get updated but the yum module
>> hangs and the role ends up in error).
>>
>> For sake of completeness, this started as an issue with a new role added
>> to Kubespray .
>> There are other details in the latest pull request comments that could help
>> to get the full picture. But in the end, even with a “raw” ansible command,
>> the issue persist, so I don’t think this is specifically related to
>> Kubespray.
>>
>> Le mercredi 9 août 2023 à 22:23:36 UTC+2, Evan Hisey a écrit :
>>
>> Check the host and see what happens on a full manual update. I have had
>> issues with ansible when the yum command was hanging on a host do to a
>> local issue with updating. Single packages were fine, but a full host
>> update failed. I had to resolve the full update issue on the host.
>>
>> On Wed, Aug 9, 2023 at 3:14 PM Nicolas Goudry  wrote:
>>
>> I’m trying to perform a full system update with the `yum` module but
>> ansible just hangs for a little bit more than an hour before failing.
>>
>> Here is the command I’m using:
>>
>> ansible all -u node-user -b --become-user=root -i exec/inventory -m yum
>> -a 'name=* state=latest' - --limit=worker1
>>
>> Here is the output (redacted):
>>
>> ansible [core 2.12.5]
>>   config file = /home/nicolas/test-upgrade-os/ansible.cfg
>>   configured module search path =
>> ['/home/nicolas/.ansible/plugins/modules',
>> '/usr/share/ansible/plugins/modules']
>>   ansible python module location =
>> /home/nicolas/test-upgrade-os/config/venv/lib64/python3.8/site-packages/ansible
>>   ansible collection location =
>> /home/nicolas/.ansible/collections:/usr/share/ansible/collections
>>   executable location = ./config/venv/bin/ansible
>>   python version = 3.8.16 (default, Jun 25 2023, 05:53:51) [GCC 8.5.0
>> 20210514 (Red Hat 8.5.0-18)]
>>   jinja version = 3.1.2
>>   libyaml = True
>> Using /home/nicolas/test-upgrade-os/ansible.cfg as config file
>> setting up inventory plugins
>> host_list declined parsing /home/nicolas/test-upgrade-os/exec/inventory
>> as it did not pass its verify_file() method
>> script declined parsing /home/nicolas/test-upgrade-os/exec/inventory as
>> it did not pass its verify_file() method
>> auto declined parsing /home/nicolas/test-upgrade-os/exec/inventory as it
>> did not pass its verify_file() method
>> Parsed /home/nicolas/test-upgrade-os/exec/inventory inventory source with
>> ini plugin
>> Loading callback plugin minimal of type stdout, v2.0 from
>> /home/nicolas/test-upgrade-os/config/venv/lib64/python3.8/site-packages/ansible/plugins/callback/minimal.py
>> Skipping callback 'default', as we

Re: [ansible-project] yum/dnf/package modules hanging on whole system update

2023-08-09 Thread Will McDonald
Looking at your verbose output, it looks like your ansible runs are
tunneled through a bastion/jumphost/proxy?

When you run your "yum update" directly on a host, are you doing:

[user@*control-node* ~]$ ssh user@target
[user@*target-node* ~] sudo yum -y update

Or are you doing:

[user@*control-node* ~]$ ssh user@*target-node* sudo yum -y update

I'm just wondering if there's something unusual in the bastion connection
handling, or the shell environment of a full interactive shell with a TTY
vs. an ansible run?

Similarly, you have your -vvv output of a *failing *run. If you do -vvv for
a *working *run, does that cast any light, indicate any differences in
behaviour in connection, privilege escalation or command invocation?

Do you have any proxies defined that may be being picked up from the
environment in an interactive session which aren't in an ansible run?


On Wed, 9 Aug 2023 at 23:15, Nicolas Goudry  wrote:

> Thanks for stepping in to help.
>
> I did run sudo yum update -y directly in one of my hosts, and everything
> went well.
>
> Also, I created the following playbook and surprisingly it works:
>
> - hosts: all
> gather_facts: no
> tasks:
> - name: YUM | Get available package updates
> yum:
> list: updates
> register: yum_available_package_updates
> - name: YUM | Update packages
> yum:
> name: "{{ yum_available_package_updates.results | map(attribute='name') |
> list }}"
> state: 'latest'
> register: yum_upgrade
> - name: YUM | Reboot after packages updates
> when:
> - yum_upgrade.changed
> reboot:
>
> However, if I use it as an ansible role, like so:
>
> ---
> - name: YUM | Get available package updates
> yum:
> list: updates
> register: yum_available_package_updates
> - name: YUM | Update packages
> yum:
> name: "{{ yum_available_package_updates.results | map(attribute='name') |
> list }}"
> state: 'latest'
> register: yum_upgrade
> - name: YUM | Reboot after packages updates
> when:
> - yum_upgrade.changed or system_upgrade_reboot == 'always'
> - system_upgrade_reboot != 'never'
> reboot:
>
> It doesn’t work (well, the system does get updated but the yum module
> hangs and the role ends up in error).
>
> For sake of completeness, this started as an issue with a new role added
> to Kubespray .
> There are other details in the latest pull request comments that could help
> to get the full picture. But in the end, even with a “raw” ansible command,
> the issue persist, so I don’t think this is specifically related to
> Kubespray.
>
> Le mercredi 9 août 2023 à 22:23:36 UTC+2, Evan Hisey a écrit :
>
> Check the host and see what happens on a full manual update. I have had
> issues with ansible when the yum command was hanging on a host do to a
> local issue with updating. Single packages were fine, but a full host
> update failed. I had to resolve the full update issue on the host.
>
> On Wed, Aug 9, 2023 at 3:14 PM Nicolas Goudry  wrote:
>
> I’m trying to perform a full system update with the `yum` module but
> ansible just hangs for a little bit more than an hour before failing.
>
> Here is the command I’m using:
>
> ansible all -u node-user -b --become-user=root -i exec/inventory -m yum -a
> 'name=* state=latest' - --limit=worker1
>
> Here is the output (redacted):
>
> ansible [core 2.12.5]
>   config file = /home/nicolas/test-upgrade-os/ansible.cfg
>   configured module search path =
> ['/home/nicolas/.ansible/plugins/modules',
> '/usr/share/ansible/plugins/modules']
>   ansible python module location =
> /home/nicolas/test-upgrade-os/config/venv/lib64/python3.8/site-packages/ansible
>   ansible collection location =
> /home/nicolas/.ansible/collections:/usr/share/ansible/collections
>   executable location = ./config/venv/bin/ansible
>   python version = 3.8.16 (default, Jun 25 2023, 05:53:51) [GCC 8.5.0
> 20210514 (Red Hat 8.5.0-18)]
>   jinja version = 3.1.2
>   libyaml = True
> Using /home/nicolas/test-upgrade-os/ansible.cfg as config file
> setting up inventory plugins
> host_list declined parsing /home/nicolas/test-upgrade-os/exec/inventory as
> it did not pass its verify_file() method
> script declined parsing /home/nicolas/test-upgrade-os/exec/inventory as it
> did not pass its verify_file() method
> auto declined parsing /home/nicolas/test-upgrade-os/exec/inventory as it
> did not pass its verify_file() method
> Parsed /home/nicolas/test-upgrade-os/exec/inventory inventory source with
> ini plugin
> Loading callback plugin minimal of type stdout, v2.0 from
> /home/nicolas/test-upgrade-os/config/venv/lib64/python3.8/site-packages/ansible/plugins/callback/minimal.py
> Skipping callback 'default', as we already have a stdout callback.
> Skipping callback 'minimal', as we already have a stdout callback.
> Skipping callback 'oneline', as we already have a stdout callback.
> META: ran handlers
> <10.10.0.101> ESTABLISH SSH CONNECTION FOR USER: node-user
> <10.10.0.101> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o
> ControlPersi

Re: [ansible-project] yum/dnf/package modules hanging on whole system update

2023-08-09 Thread Evan Hisey
A little fantasy, but nice playbook. Have you checked you transaction
history for the failed task. If there is a time out or permission issue for
the ansible user it might show up there. Another idea given your yaml is to
stick debug messages at each step to see what the output is between stages.

On Wed, Aug 9, 2023, 5:15 PM Nicolas Goudry  wrote:

> Thanks for stepping in to help.
>
> I did run sudo yum update -y directly in one of my hosts, and everything
> went well.
>
> Also, I created the following playbook and surprisingly it works:
>
> - hosts: all
> gather_facts: no
> tasks:
> - name: YUM | Get available package updates
> yum:
> list: updates
> register: yum_available_package_updates
> - name: YUM | Update packages
> yum:
> name: "{{ yum_available_package_updates.results | map(attribute='name') |
> list }}"
> state: 'latest'
> register: yum_upgrade
> - name: YUM | Reboot after packages updates
> when:
> - yum_upgrade.changed
> reboot:
>
> However, if I use it as an ansible role, like so:
>
> ---
> - name: YUM | Get available package updates
> yum:
> list: updates
> register: yum_available_package_updates
> - name: YUM | Update packages
> yum:
> name: "{{ yum_available_package_updates.results | map(attribute='name') |
> list }}"
> state: 'latest'
> register: yum_upgrade
> - name: YUM | Reboot after packages updates
> when:
> - yum_upgrade.changed or system_upgrade_reboot == 'always'
> - system_upgrade_reboot != 'never'
> reboot:
>
> It doesn’t work (well, the system does get updated but the yum module
> hangs and the role ends up in error).
>
> For sake of completeness, this started as an issue with a new role added
> to Kubespray .
> There are other details in the latest pull request comments that could help
> to get the full picture. But in the end, even with a “raw” ansible command,
> the issue persist, so I don’t think this is specifically related to
> Kubespray.
>
> Le mercredi 9 août 2023 à 22:23:36 UTC+2, Evan Hisey a écrit :
>
> Check the host and see what happens on a full manual update. I have had
> issues with ansible when the yum command was hanging on a host do to a
> local issue with updating. Single packages were fine, but a full host
> update failed. I had to resolve the full update issue on the host.
>
> On Wed, Aug 9, 2023 at 3:14 PM Nicolas Goudry  wrote:
>
> I’m trying to perform a full system update with the `yum` module but
> ansible just hangs for a little bit more than an hour before failing.
>
> Here is the command I’m using:
>
> ansible all -u node-user -b --become-user=root -i exec/inventory -m yum -a
> 'name=* state=latest' - --limit=worker1
>
> Here is the output (redacted):
>
> ansible [core 2.12.5]
>   config file = /home/nicolas/test-upgrade-os/ansible.cfg
>   configured module search path =
> ['/home/nicolas/.ansible/plugins/modules',
> '/usr/share/ansible/plugins/modules']
>   ansible python module location =
> /home/nicolas/test-upgrade-os/config/venv/lib64/python3.8/site-packages/ansible
>   ansible collection location =
> /home/nicolas/.ansible/collections:/usr/share/ansible/collections
>   executable location = ./config/venv/bin/ansible
>   python version = 3.8.16 (default, Jun 25 2023, 05:53:51) [GCC 8.5.0
> 20210514 (Red Hat 8.5.0-18)]
>   jinja version = 3.1.2
>   libyaml = True
> Using /home/nicolas/test-upgrade-os/ansible.cfg as config file
> setting up inventory plugins
> host_list declined parsing /home/nicolas/test-upgrade-os/exec/inventory as
> it did not pass its verify_file() method
> script declined parsing /home/nicolas/test-upgrade-os/exec/inventory as it
> did not pass its verify_file() method
> auto declined parsing /home/nicolas/test-upgrade-os/exec/inventory as it
> did not pass its verify_file() method
> Parsed /home/nicolas/test-upgrade-os/exec/inventory inventory source with
> ini plugin
> Loading callback plugin minimal of type stdout, v2.0 from
> /home/nicolas/test-upgrade-os/config/venv/lib64/python3.8/site-packages/ansible/plugins/callback/minimal.py
> Skipping callback 'default', as we already have a stdout callback.
> Skipping callback 'minimal', as we already have a stdout callback.
> Skipping callback 'oneline', as we already have a stdout callback.
> META: ran handlers
> <10.10.0.101> ESTABLISH SSH CONNECTION FOR USER: node-user
> <10.10.0.101> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o
> ControlPersist=60s -o KbdInteractiveAuthentication=no -o
> PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey
> -o PasswordAuthentication=no -o 'User="node-user"' -o ConnectTimeout=10 -q
> -o UserKnownHostsFile=ssh/known_hosts -i ssh/node-user -o 'ProxyCommand=ssh
> -q -o UserKnownHostsFile=ssh/known_hosts -i ssh/bastion-user -W %h:%p -p22
> bastio...@W.X.Y.Z' -o
> 'ControlPath="/home/nicolas/test-upgrade-os/config/ansible/cp/09896940d7"'
> 10.10.0.101 '/bin/sh -c '"'"'echo ~node-user && sleep 0'"'"''
> <10.10.0.101> (0, b'/home/node-user\n', b'')
> <10.10.0.10

[ansible-project] what determines which version of ansible is invoked when running ansible

2023-08-09 Thread dmastrop
hi

I have 2 versions of ansible installed on my Mac.(it was not intentional)

One version was not installed through pip and the other version was 
installed through pip.

I had to manually fix some permissions issues and now that those are 
addressed my terminal (VSCode) invokes the older version rather than the 
newer version.

*What determines which version is run when there are multiple versions on a 
computer?*
(from what I have read, pip does not install an ansible.cfg file and I 
don't know if that is where the setting is)


I thought it might be the $PATH in the terminal but the path includes both 
versions.


this is the version ansible 3.7.9(core 2.11.12). This was not installed 
through pip


 % ansible --version

[DEPRECATION WARNING]: Ansible will require Python 3.8 or newer on the 
controller starting with Ansible 2.12. Current 

*version: 3.7.9 *(v3.7.9:13c94747c7, Aug 15 2020, 01:31:08) [Clang 6.0 
(clang-600.0.57)]. This feature will be removed 

from ansible-core in version 2.12. Deprecation warnings can be disabled by 
setting deprecation_warnings=False in 

ansible.cfg.

*ansible [core 2.11.12] *

  config file = None

  configured module search path = 
['/Users/davemastropolo/.ansible/plugins/modules', 
'/usr/share/ansible/plugins/modules']

  ansible python module location = 
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ansible

  ansible collection location = 
/Users/davemastropolo/.ansible/collections:/usr/share/ansible/collections

  executable location = 
/Library/Frameworks/Python.framework/Versions/3.7/bin//ansible

  python version = 3.7.9 (v3.7.9:13c94747c7, Aug 15 2020, 01:31:08) [Clang 
6.0 (clang-600.0.57)]

  jinja version = 3.1.2

  libyaml = True




this (below) is the newer version installed through pip:

this *was* invoked through the terminal prior to fixing the permission 
issue on one of the directories (it was invoked but failing  due to the 
permission issue)


Once the permission issue was addressed, ansible now invokes the older 
version (above)



 % python3 -m pip list
Package  Version
 

*ansible  8.2.0ansible-core 2.15.2*
certifi  2023.5.7
cffi 1.15.1
cryptography 41.0.3
Jinja2   3.1.2
MarkupSafe   2.1.3
packaging23.1
pip  23.1.2
pycparser2.21
PyYAML   6.0.1
resolvelib   1.0.1
setuptools   65.5.0



warm regards

Dave


-- 
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/158f2e5f-0a55-4a18-98e5-cbadde94a98fn%40googlegroups.com.


Re: [ansible-project] yum/dnf/package modules hanging on whole system update

2023-08-09 Thread Nicolas Goudry
Thanks for stepping in to help.

I did run sudo yum update -y directly in one of my hosts, and everything 
went well.

Also, I created the following playbook and surprisingly it works:

- hosts: all
gather_facts: no
tasks:
- name: YUM | Get available package updates
yum:
list: updates
register: yum_available_package_updates
- name: YUM | Update packages
yum:
name: "{{ yum_available_package_updates.results | map(attribute='name') | 
list }}"
state: 'latest'
register: yum_upgrade
- name: YUM | Reboot after packages updates
when:
- yum_upgrade.changed
reboot:

However, if I use it as an ansible role, like so:

---
- name: YUM | Get available package updates
yum:
list: updates
register: yum_available_package_updates
- name: YUM | Update packages
yum:
name: "{{ yum_available_package_updates.results | map(attribute='name') | 
list }}"
state: 'latest'
register: yum_upgrade
- name: YUM | Reboot after packages updates
when:
- yum_upgrade.changed or system_upgrade_reboot == 'always'
- system_upgrade_reboot != 'never'
reboot: 

It doesn’t work (well, the system does get updated but the yum module hangs 
and the role ends up in error).

For sake of completeness, this started as an issue with a new role added to 
Kubespray . There 
are other details in the latest pull request comments that could help to 
get the full picture. But in the end, even with a “raw” ansible command, 
the issue persist, so I don’t think this is specifically related to 
Kubespray.

Le mercredi 9 août 2023 à 22:23:36 UTC+2, Evan Hisey a écrit :

Check the host and see what happens on a full manual update. I have had 
issues with ansible when the yum command was hanging on a host do to a 
local issue with updating. Single packages were fine, but a full host 
update failed. I had to resolve the full update issue on the host. 

On Wed, Aug 9, 2023 at 3:14 PM Nicolas Goudry  wrote:

I’m trying to perform a full system update with the `yum` module but 
ansible just hangs for a little bit more than an hour before failing.

Here is the command I’m using:

ansible all -u node-user -b --become-user=root -i exec/inventory -m yum -a 
'name=* state=latest' - --limit=worker1

Here is the output (redacted):

ansible [core 2.12.5]
  config file = /home/nicolas/test-upgrade-os/ansible.cfg
  configured module search path = 
['/home/nicolas/.ansible/plugins/modules', 
'/usr/share/ansible/plugins/modules']
  ansible python module location = 
/home/nicolas/test-upgrade-os/config/venv/lib64/python3.8/site-packages/ansible
  ansible collection location = 
/home/nicolas/.ansible/collections:/usr/share/ansible/collections
  executable location = ./config/venv/bin/ansible
  python version = 3.8.16 (default, Jun 25 2023, 05:53:51) [GCC 8.5.0 
20210514 (Red Hat 8.5.0-18)]
  jinja version = 3.1.2
  libyaml = True
Using /home/nicolas/test-upgrade-os/ansible.cfg as config file
setting up inventory plugins
host_list declined parsing /home/nicolas/test-upgrade-os/exec/inventory as 
it did not pass its verify_file() method
script declined parsing /home/nicolas/test-upgrade-os/exec/inventory as it 
did not pass its verify_file() method
auto declined parsing /home/nicolas/test-upgrade-os/exec/inventory as it 
did not pass its verify_file() method
Parsed /home/nicolas/test-upgrade-os/exec/inventory inventory source with 
ini plugin
Loading callback plugin minimal of type stdout, v2.0 from 
/home/nicolas/test-upgrade-os/config/venv/lib64/python3.8/site-packages/ansible/plugins/callback/minimal.py
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.
META: ran handlers
<10.10.0.101> ESTABLISH SSH CONNECTION FOR USER: node-user
<10.10.0.101> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o 
ControlPersist=60s -o KbdInteractiveAuthentication=no -o 
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey 
-o PasswordAuthentication=no -o 'User="node-user"' -o ConnectTimeout=10 -q 
-o UserKnownHostsFile=ssh/known_hosts -i ssh/node-user -o 'ProxyCommand=ssh 
-q -o UserKnownHostsFile=ssh/known_hosts -i ssh/bastion-user -W %h:%p -p22 
bastio...@W.X.Y.Z' -o 
'ControlPath="/home/nicolas/test-upgrade-os/config/ansible/cp/09896940d7"' 
10.10.0.101 '/bin/sh -c '"'"'echo ~node-user && sleep 0'"'"''
<10.10.0.101> (0, b'/home/node-user\n', b'')
<10.10.0.101> ESTABLISH SSH CONNECTION FOR USER: node-user
<10.10.0.101> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o 
ControlPersist=60s -o KbdInteractiveAuthentication=no -o 
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey 
-o PasswordAuthentication=no -o 'User="node-user"' -o ConnectTimeout=10 -q 
-o UserKnownHostsFile=ssh/known_hosts -i ssh/node-user -o 'ProxyCommand=ssh 
-q -o UserKnownHostsFile=ssh/known_hosts -i ssh/bastion-user -W %h:%p -p22 
bastio...@W.X.Y.Z' -o 
'ControlPath="/home/nicolas/test-upgra

Re: [ansible-project] Ansible playbook undefined variable

2023-08-09 Thread Rilindo Foster
Hi Hernan,

Your variable is actually a data structure of a list of dictionary:

admin:
  - name: 'herlit_semaphore'
comment: 'Ultimate User'
uid: '1000'

  - name: 'semaphore'
comment: 'Semaphore App User'
uid: '1001'



If you don’t intend to do loop, you simply reference the item directly. For 
example, for “herlit_semaphore” user, you do:

- name: Add the user with a specific uid and a primary group of "admin"
  ansible.builtin.user:
name: "{{ admin[0].name }}"
comment: "{{ admin[0].comment }}"
uid: "{{ admin[0].uid }}"
state: present
group: admin
append: yes

Where [0] is the first element in the list that contains that user. For the 
second user, it is going to be:


- name: Add the user "semaphore" with a specific uid and a primary group of 
"admin"
  ansible.builtin.user:
name: "{{ admin[1].name }}"
comment: "{{ admin[1].comment }}"
uid: "{{ admin[1].uid }}"
state: present
group: admin
append: yes


Where [1] is the second element in the list and th one that contains the 
“semaphore” user.

You can confirm the placement by pasting:

admin:
  - name: 'herlit_semaphore'
comment: 'Ultimate User'
uid: '1000'

  - name: 'semaphore'
comment: 'Semaphore App User'
uid: ‘1001'

Into:


https://jsonformatter.org/yaml-viewer
Best YAML Viewer Online
jsonformatter.org

And click on “YAML Viewer” to browse around the list.

Note that unless there is a good reason, it would be better to loop around that 
data structure, as it mean much less code.

- Rilindo


> On Aug 9, 2023, at 3:05 PM, Hernan Sal  wrote:
> 
> Hi,
> I'm running an ansible playbook called create_admin_user.yml and I'm getting
> this error
> 
> fatal: [172.31.3.117]: FAILED! => {"msg": "The task includes an option with 
> an undefined variable. The error was: 'herlit_semaphore' is undefined. 
> 'herlit_semaphore' is undefined\n\nThe error appears to be in 
> '/etc/ansible/roles/create_admin_user/tasks/main.yml': line 13, column 3, but 
> may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe 
> offending line appears to be:\n\n\n- name:  semaphore\n  ^ here\n"}
> 
> This is my create_admin_user.yaml file in  the playbooks/users directory
> - hosts: all
>   gather_facts: yes
>   become: yes
>   become_user: root
>   tasks:
> - ansible.builtin.import_role:
> name: create_admin_user
> 
> This is my main.yml in the vars directory
> admin:
>   - name: 'herlit_semaphore'
> comment: 'Ultimate User'
> uid: '1000'
> 
>   - name: 'semaphore'
> comment: 'Semaphore App User'
> uid: '1001'
> 
> This is my main.yml in the tasks directory
> ---
> # tasks file for create_admin_user
> 
> - name: Add the user with a specific uid and a primary group of "admin"
>   ansible.builtin.user:
> name: "{{ herlit_semaphore.name }}"
> comment: "{{ herlit_semaphore.comment }}"
> uid: "{{ herlit_semaphore.uid }}"
> state: present
> group: admin
> append: yes
> 
> - name: Add the user "semaphore" with a specific uid and a primary group of 
> "admin"
>   ansible.builtin.user:
> name: "{{ semaphore.name }}"
> comment: "{{ semaphore.comment }}"
> uid: "{{ semaphore.uid }}"
> state: present
> group: admin
> append: yes
> 
> Sorry for the long email. Any ideas about this error?
> THanks
> Hernan
> 
> -- 
> 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/269931b4-2003-41cf-8321-7e04ac730488n%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/711AE5BA-19B9-4C8D-9CB2-1B69D2FD636A%40gmail.com.


Re: [ansible-project] yum/dnf/package modules hanging on whole system update

2023-08-09 Thread Evan Hisey
Check the host and see what happens on a full manual update. I have had
issues with ansible when the yum command was hanging on a host do to a
local issue with updating. Single packages were fine, but a full host
update failed. I had to resolve the full update issue on the host.

On Wed, Aug 9, 2023 at 3:14 PM Nicolas Goudry  wrote:

> I’m trying to perform a full system update with the `yum` module but
> ansible just hangs for a little bit more than an hour before failing.
>
> Here is the command I’m using:
>
> ansible all -u node-user -b --become-user=root -i exec/inventory -m yum -a
> 'name=* state=latest' - --limit=worker1
>
> Here is the output (redacted):
>
> ansible [core 2.12.5]
>   config file = /home/nicolas/test-upgrade-os/ansible.cfg
>   configured module search path =
> ['/home/nicolas/.ansible/plugins/modules',
> '/usr/share/ansible/plugins/modules']
>   ansible python module location =
> /home/nicolas/test-upgrade-os/config/venv/lib64/python3.8/site-packages/ansible
>   ansible collection location =
> /home/nicolas/.ansible/collections:/usr/share/ansible/collections
>   executable location = ./config/venv/bin/ansible
>   python version = 3.8.16 (default, Jun 25 2023, 05:53:51) [GCC 8.5.0
> 20210514 (Red Hat 8.5.0-18)]
>   jinja version = 3.1.2
>   libyaml = True
> Using /home/nicolas/test-upgrade-os/ansible.cfg as config file
> setting up inventory plugins
> host_list declined parsing /home/nicolas/test-upgrade-os/exec/inventory as
> it did not pass its verify_file() method
> script declined parsing /home/nicolas/test-upgrade-os/exec/inventory as it
> did not pass its verify_file() method
> auto declined parsing /home/nicolas/test-upgrade-os/exec/inventory as it
> did not pass its verify_file() method
> Parsed /home/nicolas/test-upgrade-os/exec/inventory inventory source with
> ini plugin
> Loading callback plugin minimal of type stdout, v2.0 from
> /home/nicolas/test-upgrade-os/config/venv/lib64/python3.8/site-packages/ansible/plugins/callback/minimal.py
> Skipping callback 'default', as we already have a stdout callback.
> Skipping callback 'minimal', as we already have a stdout callback.
> Skipping callback 'oneline', as we already have a stdout callback.
> META: ran handlers
> <10.10.0.101> ESTABLISH SSH CONNECTION FOR USER: node-user
> <10.10.0.101> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o
> ControlPersist=60s -o KbdInteractiveAuthentication=no -o
> PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey
> -o PasswordAuthentication=no -o 'User="node-user"' -o ConnectTimeout=10 -q
> -o UserKnownHostsFile=ssh/known_hosts -i ssh/node-user -o 'ProxyCommand=ssh
> -q -o UserKnownHostsFile=ssh/known_hosts -i ssh/bastion-user -W %h:%p -p22
> bastion-user@W.X.Y.Z' -o
> 'ControlPath="/home/nicolas/test-upgrade-os/config/ansible/cp/09896940d7"'
> 10.10.0.101 '/bin/sh -c '"'"'echo ~node-user && sleep 0'"'"''
> <10.10.0.101> (0, b'/home/node-user\n', b'')
> <10.10.0.101> ESTABLISH SSH CONNECTION FOR USER: node-user
> <10.10.0.101> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o
> ControlPersist=60s -o KbdInteractiveAuthentication=no -o
> PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey
> -o PasswordAuthentication=no -o 'User="node-user"' -o ConnectTimeout=10 -q
> -o UserKnownHostsFile=ssh/known_hosts -i ssh/node-user -o 'ProxyCommand=ssh
> -q -o UserKnownHostsFile=ssh/known_hosts -i ssh/bastion-user -W %h:%p -p22
> bastion-user@W.X.Y.Z' -o
> 'ControlPath="/home/nicolas/test-upgrade-os/config/ansible/cp/09896940d7"'
> 10.10.0.101 '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo
> /home/node-user/.ansible/tmp `"&& mkdir "` echo
> /home/node-user/.ansible/tmp/ansible-tmp-1691583637.8116903-3768362-148267575047576
> `" && echo ansible-tmp-1691583637.8116903-3768362-148267575047576="` echo
> /home/node-user/.ansible/tmp/ansible-tmp-1691583637.8116903-3768362-148267575047576
> `" ) && sleep 0'"'"''
> <10.10.0.101> (0,
> b'ansible-tmp-1691583637.8116903-3768362-148267575047576=/home/node-user/.ansible/tmp/ansible-tmp-1691583637.8116903-3768362-148267575047576\n',
> b'')
>  Attempting python interpreter discovery
> <10.10.0.101> ESTABLISH SSH CONNECTION FOR USER: node-user
> <10.10.0.101> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o
> ControlPersist=60s -o KbdInteractiveAuthentication=no -o
> PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey
> -o PasswordAuthentication=no -o 'User="node-user"' -o ConnectTimeout=10 -q
> -o UserKnownHostsFile=ssh/known_hosts -i ssh/node-user -o 'ProxyCommand=ssh
> -q -o UserKnownHostsFile=ssh/known_hosts -i ssh/bastion-user -W %h:%p -p22
> bastion-user@W.X.Y.Z' -o
> 'ControlPath="/home/nicolas/test-upgrade-os/config/ansible/cp/09896940d7"'
> 10.10.0.101 '/bin/sh -c '"'"'echo PLATFORM; uname; echo FOUND; command -v
> '"'"'"'"'"'"'"'"'python3.10'"'"'"'"'"'"'"'"'; command -v
> '"'"'"'"'"'"'"'"'python3.9'"'"'"'"'"'"'"'"'; command -v
> '"'"'"'"'"'"'"'"'python3.8'"'"'"'"'"'"'"'"'; command -v
> '"'"'"'"'"'"

[ansible-project] yum/dnf/package modules hanging on whole system update

2023-08-09 Thread Nicolas Goudry
I’m trying to perform a full system update with the `yum` module but 
ansible just hangs for a little bit more than an hour before failing.

Here is the command I’m using:

ansible all -u node-user -b --become-user=root -i exec/inventory -m yum -a 
'name=* state=latest' - --limit=worker1

Here is the output (redacted):

ansible [core 2.12.5]
  config file = /home/nicolas/test-upgrade-os/ansible.cfg
  configured module search path = 
['/home/nicolas/.ansible/plugins/modules', 
'/usr/share/ansible/plugins/modules']
  ansible python module location = 
/home/nicolas/test-upgrade-os/config/venv/lib64/python3.8/site-packages/ansible
  ansible collection location = 
/home/nicolas/.ansible/collections:/usr/share/ansible/collections
  executable location = ./config/venv/bin/ansible
  python version = 3.8.16 (default, Jun 25 2023, 05:53:51) [GCC 8.5.0 
20210514 (Red Hat 8.5.0-18)]
  jinja version = 3.1.2
  libyaml = True
Using /home/nicolas/test-upgrade-os/ansible.cfg as config file
setting up inventory plugins
host_list declined parsing /home/nicolas/test-upgrade-os/exec/inventory as 
it did not pass its verify_file() method
script declined parsing /home/nicolas/test-upgrade-os/exec/inventory as it 
did not pass its verify_file() method
auto declined parsing /home/nicolas/test-upgrade-os/exec/inventory as it 
did not pass its verify_file() method
Parsed /home/nicolas/test-upgrade-os/exec/inventory inventory source with 
ini plugin
Loading callback plugin minimal of type stdout, v2.0 from 
/home/nicolas/test-upgrade-os/config/venv/lib64/python3.8/site-packages/ansible/plugins/callback/minimal.py
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.
META: ran handlers
<10.10.0.101> ESTABLISH SSH CONNECTION FOR USER: node-user
<10.10.0.101> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o 
ControlPersist=60s -o KbdInteractiveAuthentication=no -o 
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey 
-o PasswordAuthentication=no -o 'User="node-user"' -o ConnectTimeout=10 -q 
-o UserKnownHostsFile=ssh/known_hosts -i ssh/node-user -o 'ProxyCommand=ssh 
-q -o UserKnownHostsFile=ssh/known_hosts -i ssh/bastion-user -W %h:%p -p22 
bastion-user@W.X.Y.Z' -o 
'ControlPath="/home/nicolas/test-upgrade-os/config/ansible/cp/09896940d7"' 
10.10.0.101 '/bin/sh -c '"'"'echo ~node-user && sleep 0'"'"''
<10.10.0.101> (0, b'/home/node-user\n', b'')
<10.10.0.101> ESTABLISH SSH CONNECTION FOR USER: node-user
<10.10.0.101> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o 
ControlPersist=60s -o KbdInteractiveAuthentication=no -o 
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey 
-o PasswordAuthentication=no -o 'User="node-user"' -o ConnectTimeout=10 -q 
-o UserKnownHostsFile=ssh/known_hosts -i ssh/node-user -o 'ProxyCommand=ssh 
-q -o UserKnownHostsFile=ssh/known_hosts -i ssh/bastion-user -W %h:%p -p22 
bastion-user@W.X.Y.Z' -o 
'ControlPath="/home/nicolas/test-upgrade-os/config/ansible/cp/09896940d7"' 
10.10.0.101 '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo 
/home/node-user/.ansible/tmp `"&& mkdir "` echo 
/home/node-user/.ansible/tmp/ansible-tmp-1691583637.8116903-3768362-148267575047576
 
`" && echo ansible-tmp-1691583637.8116903-3768362-148267575047576="` echo 
/home/node-user/.ansible/tmp/ansible-tmp-1691583637.8116903-3768362-148267575047576
 
`" ) && sleep 0'"'"''
<10.10.0.101> (0, 
b'ansible-tmp-1691583637.8116903-3768362-148267575047576=/home/node-user/.ansible/tmp/ansible-tmp-1691583637.8116903-3768362-148267575047576\n',
 
b'')
 Attempting python interpreter discovery
<10.10.0.101> ESTABLISH SSH CONNECTION FOR USER: node-user
<10.10.0.101> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o 
ControlPersist=60s -o KbdInteractiveAuthentication=no -o 
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey 
-o PasswordAuthentication=no -o 'User="node-user"' -o ConnectTimeout=10 -q 
-o UserKnownHostsFile=ssh/known_hosts -i ssh/node-user -o 'ProxyCommand=ssh 
-q -o UserKnownHostsFile=ssh/known_hosts -i ssh/bastion-user -W %h:%p -p22 
bastion-user@W.X.Y.Z' -o 
'ControlPath="/home/nicolas/test-upgrade-os/config/ansible/cp/09896940d7"' 
10.10.0.101 '/bin/sh -c '"'"'echo PLATFORM; uname; echo FOUND; command -v 
'"'"'"'"'"'"'"'"'python3.10'"'"'"'"'"'"'"'"'; command -v 
'"'"'"'"'"'"'"'"'python3.9'"'"'"'"'"'"'"'"'; command -v 
'"'"'"'"'"'"'"'"'python3.8'"'"'"'"'"'"'"'"'; command -v 
'"'"'"'"'"'"'"'"'python3.7'"'"'"'"'"'"'"'"'; command -v 
'"'"'"'"'"'"'"'"'python3.6'"'"'"'"'"'"'"'"'; command -v 
'"'"'"'"'"'"'"'"'python3.5'"'"'"'"'"'"'"'"'; command -v 
'"'"'"'"'"'"'"'"'/usr/bin/python3'"'"'"'"'"'"'"'"'; command -v 
'"'"'"'"'"'"'"'"'/usr/libexec/platform-python'"'"'"'"'"'"'"'"'; command -v 
'"'"'"'"'"'"'"'"'python2.7'"'"'"'"'"'"'"'"'; command -v 
'"'"'"'"'"'"'"'"'python2.6'"'"'"'"'"'"'"'"'; command -v 
'"'"'"'"'"'"'"'"'/usr/bin/python'"'"'

[ansible-project] Ansible playbook undefined variable

2023-08-09 Thread Hernan Sal
Hi,
I'm running an ansible playbook called create_admin_user.yml and I'm getting
this error

fatal: [172.31.3.117]: FAILED! => {"msg": "The task includes an option with 
an undefined variable. The error was: 'herlit_semaphore' is undefined. 
'herlit_semaphore' is undefined\n\nThe error appears to be in 
'/etc/ansible/roles/create_admin_user/tasks/main.yml': line 13, column 3, 
but may\nbe elsewhere in the file depending on the exact syntax 
problem.\n\nThe offending line appears to be:\n\n\n- name:  semaphore\n  ^ 
here\n"}

This is my create_admin_user.yaml file in  the playbooks/users directory
- hosts: all
  gather_facts: yes
  become: yes
  become_user: root
  tasks:
- ansible.builtin.import_role:
name: create_admin_user

This is my main.yml in the vars directory
admin:
  - name: 'herlit_semaphore'
comment: 'Ultimate User'
uid: '1000'

  - name: 'semaphore'
comment: 'Semaphore App User'
uid: '1001'

This is my main.yml in the tasks directory
---
# tasks file for create_admin_user

- name: Add the user with a specific uid and a primary group of "admin"
  ansible.builtin.user:
name: "{{ herlit_semaphore.name }}"
comment: "{{ herlit_semaphore.comment }}"
uid: "{{ herlit_semaphore.uid }}"
state: present
group: admin
append: yes

- name: Add the user "semaphore" with a specific uid and a primary group of 
"admin"
  ansible.builtin.user:
name: "{{ semaphore.name }}"
comment: "{{ semaphore.comment }}"
uid: "{{ semaphore.uid }}"
state: present
group: admin
append: yes

Sorry for the long email. Any ideas about this error?
THanks
Hernan

-- 
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/269931b4-2003-41cf-8321-7e04ac730488n%40googlegroups.com.


Re: [ansible-project] Mail module - multiple tabs in csv file

2023-08-09 Thread Sumanth Parakala
Try using a python to merge csvs into xlsx and shell module before mail
module.
--
localhost@root tmp # cat csv_xlsx_combine.py
import pandas as pd

csv1_data = pd.read_csv('file1.csv')
csv2_data = pd.read_csv('file2.csv')

xlsx_writer = pd.ExcelWriter('output.xlsx', engine='openpyxl')

csv1_data.to_excel(xlsx_writer, sheet_name='Sheet1', index=False)
csv2_data.to_excel(xlsx_writer, sheet_name='Sheet2', index=False)

xlsx_writer.save()
-
for above python code to work, you ll need pandas and openpyxl modules
install alongside python3
pip install pandas
pip install openpyxl

--


tasks:

- name: Preparing attachment
  shell: |
  python3 /tmp/csv_xlsx_combine.py
  ls /tmp/output.xlsx && echo "Good to go"


- name: Sendmail
  community.general.mail:
subject: "{{ email_subject }}"
body: "{{ email_body }}"
attach: "/tmp/output.xlsx"
sender: "{{ email_sender }}"
to: "{{ email_recipient }}"
host: "{{ smtp_host }}"
port: "{{ smtp_port }}"
username: "{{ smtp_username }}"
password: "{{ smtp_password }}"
  delegate_to: localhost
- debug:
msg: "Mail sent successfully"


this should work

On Wed, 9 Aug 2023 at 18:23, Aharonu  wrote:

> Noted.
>
> Thank you!
>
> On Wed, 9 Aug 2023, 18:17 Evan Hisey,  wrote:
>
>> I would send it as two files and let the user integrate to one file if
>> they prefer since it is not a technical requirement of usage. Csv as you
>> note does not support tabs. With out a hard technical requirement the
>> effort to supply tabs may exceed the value.
>>
>> On Wed, Aug 9, 2023, 7:42 AM Thanh Nguyen Duc 
>> wrote:
>>
>>> Technically csv doesn’t support multiple tabs so it is not able to
>>> achieve.
>>>
>>> Thanks and Best Regards,
>>>
>>> Thanh.
>>>
>>> On 9 Aug 2023, at 19:39, Aharonu  wrote:
>>>
>>> 
>>> Hi Evan Hisey,
>>>
>>> Thanks for your response.
>>>
>>> It is end user requested preferences. We don't need to avoid multiple
>>> files but segerate required data in one csv file with multiple tabs.
>>>
>>> Example,
>>> If I want to pull filesystem which are online and offline staus. We need
>>> both in one file cvs ox excel  but two different tabs.
>>>
>>> File1.cvs
>>>Tab1: Off_fs
>>>Tab2: On_fs
>>>
>>>
>>> On Wed, 9 Aug 2023, 17:57 Evan Hisey,  wrote:
>>>
 Try starting with reviewing the problem the solution is trying to
 solve. Why does it have too be two tabs? Is it a technical requirement or
 just a preference? What will be consuming the data? Can it be used as two
 cvs?

 On Wednesday, August 9, 2023 at 6:56:50 AM UTC-5 Aharonu wrote:

> Thank you. Even I am not much aware of Python coming in advance level.
>
> It looks like big task. I will wait anyone suggest us more better way
>
> On Wed, 9 Aug 2023, 17:15 Thanh Nguyen Duc, 
> wrote:
>
>> Hope can help. I am not python programmer so code may not clean.
>> from ansible.module_utils.basic import *
>> import sys
>> import os
>> import csv
>> import xlsxwriter
>> import glob
>> import codecs
>> import pwd
>> import grp
>> def main():
>> fields = {
>> "csv_dir": {"required": True, "type": "str"},
>> "output_xlsx_file": {"required": True, "type": "str"},
>> "format_header": {"required": True, "type": "bool"},
>> "format_error": {"required": False, "type": "list"},
>> "format_correct": {"required": False, "type": "list"},
>> "owner": {"required": False, "type": "str"},
>> "group": {"required": False, "type": "str"},
>> "split_data": {"required": False, "type": "bool"},
>> "summary_csv_list": {"required": False, "type": "list", "default":
>> []},
>> }
>> module = AnsibleModule(argument_spec=fields)
>> wb = xlsxwriter.Workbook(module.params['output_xlsx_file'])
>> format_header = wb.add_format()
>> format_header.set_bold()
>> format_header.set_bg_color('blue')
>> format_header.set_font_color('white')
>> f1 = wb.add_format({'bg_color': 'red', 'font_color': 'black', 'bold':
>> True })
>> f2 = wb.add_format({'bg_color': 'green', 'font_color': 'black',
>> 'bold': True })
>> f3 = wb.add_format({'border':1, 'border_color':'black', 'text_wrap':
>> True})
>> csv_dir = module.params['csv_dir']
>> csv_file_list = sorted(glob.glob(csv_dir + '/*.csv'))
>> summary_worksheets = []
>> for summary_filename_csv in module.params['summary_csv_list']:
>> summary_csv_file_path = os.path.join(csv_dir, summary_filename_csv)
>> summary_sheet_title =
>> os.path.splitext(os.path.basename(summary_csv_file_path))[0][0:31]
>> summary_ws = wb.add_worksheet(summary_sheet_title)
>> with codecs.open(summary_csv_file_path, 

Re: [ansible-project] Mail module - multiple tabs in csv file

2023-08-09 Thread Aharonu
Noted.

Thank you!

On Wed, 9 Aug 2023, 18:17 Evan Hisey,  wrote:

> I would send it as two files and let the user integrate to one file if
> they prefer since it is not a technical requirement of usage. Csv as you
> note does not support tabs. With out a hard technical requirement the
> effort to supply tabs may exceed the value.
>
> On Wed, Aug 9, 2023, 7:42 AM Thanh Nguyen Duc 
> wrote:
>
>> Technically csv doesn’t support multiple tabs so it is not able to
>> achieve.
>>
>> Thanks and Best Regards,
>>
>> Thanh.
>>
>> On 9 Aug 2023, at 19:39, Aharonu  wrote:
>>
>> 
>> Hi Evan Hisey,
>>
>> Thanks for your response.
>>
>> It is end user requested preferences. We don't need to avoid multiple
>> files but segerate required data in one csv file with multiple tabs.
>>
>> Example,
>> If I want to pull filesystem which are online and offline staus. We need
>> both in one file cvs ox excel  but two different tabs.
>>
>> File1.cvs
>>Tab1: Off_fs
>>Tab2: On_fs
>>
>>
>> On Wed, 9 Aug 2023, 17:57 Evan Hisey,  wrote:
>>
>>> Try starting with reviewing the problem the solution is trying to solve.
>>> Why does it have too be two tabs? Is it a technical requirement or just a
>>> preference? What will be consuming the data? Can it be used as two cvs?
>>>
>>> On Wednesday, August 9, 2023 at 6:56:50 AM UTC-5 Aharonu wrote:
>>>
 Thank you. Even I am not much aware of Python coming in advance level.

 It looks like big task. I will wait anyone suggest us more better way

 On Wed, 9 Aug 2023, 17:15 Thanh Nguyen Duc, 
 wrote:

> Hope can help. I am not python programmer so code may not clean.
> from ansible.module_utils.basic import *
> import sys
> import os
> import csv
> import xlsxwriter
> import glob
> import codecs
> import pwd
> import grp
> def main():
> fields = {
> "csv_dir": {"required": True, "type": "str"},
> "output_xlsx_file": {"required": True, "type": "str"},
> "format_header": {"required": True, "type": "bool"},
> "format_error": {"required": False, "type": "list"},
> "format_correct": {"required": False, "type": "list"},
> "owner": {"required": False, "type": "str"},
> "group": {"required": False, "type": "str"},
> "split_data": {"required": False, "type": "bool"},
> "summary_csv_list": {"required": False, "type": "list", "default": []},
> }
> module = AnsibleModule(argument_spec=fields)
> wb = xlsxwriter.Workbook(module.params['output_xlsx_file'])
> format_header = wb.add_format()
> format_header.set_bold()
> format_header.set_bg_color('blue')
> format_header.set_font_color('white')
> f1 = wb.add_format({'bg_color': 'red', 'font_color': 'black', 'bold':
> True })
> f2 = wb.add_format({'bg_color': 'green', 'font_color': 'black',
> 'bold': True })
> f3 = wb.add_format({'border':1, 'border_color':'black', 'text_wrap':
> True})
> csv_dir = module.params['csv_dir']
> csv_file_list = sorted(glob.glob(csv_dir + '/*.csv'))
> summary_worksheets = []
> for summary_filename_csv in module.params['summary_csv_list']:
> summary_csv_file_path = os.path.join(csv_dir, summary_filename_csv)
> summary_sheet_title =
> os.path.splitext(os.path.basename(summary_csv_file_path))[0][0:31]
> summary_ws = wb.add_worksheet(summary_sheet_title)
> with codecs.open(summary_csv_file_path, 'r') as summary_csvfile:
> summary_table = csv.reader((l.replace('\0', '') for l in
> summary_csvfile))
> summary_num_row = 0
> summary_num_cols = 0
> summary_columns_width = []
> for summary_row in summary_table:
> if module.params['format_header'] and summary_num_row == 0:
> summary_ws.write_row(summary_num_row, 0, summary_row, format_header)
> else:
> modified_summary_row = []
> for item in summary_row:
> modified_summary_row.append(item)
> summary_ws.write_row(summary_num_row, 0, modified_summary_row, f3)
> summary_num_row += 1
> summary_num_cols = max(summary_num_cols, len(summary_row))
> summary_columns_width = [max(len(j), summary_columns_width[i] if
> len(summary_columns_width) > i else 1) for i, j in enumerate(summary_row)]
> # Simulate autofit column
> for i, j in enumerate(summary_columns_width):
> column_name = "%s:%s" % (chr(ord('A') + i), chr(ord('A') + i))
> summary_ws.set_column(column_name, j)
> summary_worksheets.append(summary_ws)
> summary_ws.autofit()
> summary_ws.conditional_format(
> 'C2:C1',
> {'type': 'no_blanks', 'format': f2}
> )
> summary_ws.conditional_format(
> 'D2:D1',
> {'type': 'no_blanks', 'format': f1}
> )
> # Move the summary sheets to the first position
> for summary_ws in summary_worksheets:
> summary_ws.set_first_sheet()
> for csv_file_path in csv_file_list:
> if os.path.basename(csv_file_path) in
> module.params['summary_csv_list']:
> continue
> she

Re: [ansible-project] Mail module - multiple tabs in csv file

2023-08-09 Thread Evan Hisey
I would send it as two files and let the user integrate to one file if they
prefer since it is not a technical requirement of usage. Csv as you note
does not support tabs. With out a hard technical requirement the effort to
supply tabs may exceed the value.

On Wed, Aug 9, 2023, 7:42 AM Thanh Nguyen Duc 
wrote:

> Technically csv doesn’t support multiple tabs so it is not able to achieve.
>
> Thanks and Best Regards,
>
> Thanh.
>
> On 9 Aug 2023, at 19:39, Aharonu  wrote:
>
> 
> Hi Evan Hisey,
>
> Thanks for your response.
>
> It is end user requested preferences. We don't need to avoid multiple
> files but segerate required data in one csv file with multiple tabs.
>
> Example,
> If I want to pull filesystem which are online and offline staus. We need
> both in one file cvs ox excel  but two different tabs.
>
> File1.cvs
>Tab1: Off_fs
>Tab2: On_fs
>
>
> On Wed, 9 Aug 2023, 17:57 Evan Hisey,  wrote:
>
>> Try starting with reviewing the problem the solution is trying to solve.
>> Why does it have too be two tabs? Is it a technical requirement or just a
>> preference? What will be consuming the data? Can it be used as two cvs?
>>
>> On Wednesday, August 9, 2023 at 6:56:50 AM UTC-5 Aharonu wrote:
>>
>>> Thank you. Even I am not much aware of Python coming in advance level.
>>>
>>> It looks like big task. I will wait anyone suggest us more better way
>>>
>>> On Wed, 9 Aug 2023, 17:15 Thanh Nguyen Duc, 
>>> wrote:
>>>
 Hope can help. I am not python programmer so code may not clean.
 from ansible.module_utils.basic import *
 import sys
 import os
 import csv
 import xlsxwriter
 import glob
 import codecs
 import pwd
 import grp
 def main():
 fields = {
 "csv_dir": {"required": True, "type": "str"},
 "output_xlsx_file": {"required": True, "type": "str"},
 "format_header": {"required": True, "type": "bool"},
 "format_error": {"required": False, "type": "list"},
 "format_correct": {"required": False, "type": "list"},
 "owner": {"required": False, "type": "str"},
 "group": {"required": False, "type": "str"},
 "split_data": {"required": False, "type": "bool"},
 "summary_csv_list": {"required": False, "type": "list", "default": []},
 }
 module = AnsibleModule(argument_spec=fields)
 wb = xlsxwriter.Workbook(module.params['output_xlsx_file'])
 format_header = wb.add_format()
 format_header.set_bold()
 format_header.set_bg_color('blue')
 format_header.set_font_color('white')
 f1 = wb.add_format({'bg_color': 'red', 'font_color': 'black', 'bold':
 True })
 f2 = wb.add_format({'bg_color': 'green', 'font_color': 'black', 'bold':
 True })
 f3 = wb.add_format({'border':1, 'border_color':'black', 'text_wrap':
 True})
 csv_dir = module.params['csv_dir']
 csv_file_list = sorted(glob.glob(csv_dir + '/*.csv'))
 summary_worksheets = []
 for summary_filename_csv in module.params['summary_csv_list']:
 summary_csv_file_path = os.path.join(csv_dir, summary_filename_csv)
 summary_sheet_title =
 os.path.splitext(os.path.basename(summary_csv_file_path))[0][0:31]
 summary_ws = wb.add_worksheet(summary_sheet_title)
 with codecs.open(summary_csv_file_path, 'r') as summary_csvfile:
 summary_table = csv.reader((l.replace('\0', '') for l in
 summary_csvfile))
 summary_num_row = 0
 summary_num_cols = 0
 summary_columns_width = []
 for summary_row in summary_table:
 if module.params['format_header'] and summary_num_row == 0:
 summary_ws.write_row(summary_num_row, 0, summary_row, format_header)
 else:
 modified_summary_row = []
 for item in summary_row:
 modified_summary_row.append(item)
 summary_ws.write_row(summary_num_row, 0, modified_summary_row, f3)
 summary_num_row += 1
 summary_num_cols = max(summary_num_cols, len(summary_row))
 summary_columns_width = [max(len(j), summary_columns_width[i] if
 len(summary_columns_width) > i else 1) for i, j in enumerate(summary_row)]
 # Simulate autofit column
 for i, j in enumerate(summary_columns_width):
 column_name = "%s:%s" % (chr(ord('A') + i), chr(ord('A') + i))
 summary_ws.set_column(column_name, j)
 summary_worksheets.append(summary_ws)
 summary_ws.autofit()
 summary_ws.conditional_format(
 'C2:C1',
 {'type': 'no_blanks', 'format': f2}
 )
 summary_ws.conditional_format(
 'D2:D1',
 {'type': 'no_blanks', 'format': f1}
 )
 # Move the summary sheets to the first position
 for summary_ws in summary_worksheets:
 summary_ws.set_first_sheet()
 for csv_file_path in csv_file_list:
 if os.path.basename(csv_file_path) in module.params['summary_csv_list']:
 continue
 sheet_title = os.path.splitext(os.path.basename(csv_file_path))[0][0:31]
 ws = wb.add_worksheet(sheet_title)
 with codecs.open(csv_file_path, 'r') as csvfile:
 table = csv.reader((l.replace('\0', '') fo

Re: [ansible-project] Mail module - multiple tabs in csv file

2023-08-09 Thread Aharonu
If not with csv, may I know if possible with exceel or xlsx..etc.Thx

On Wed, 9 Aug 2023, 18:12 Thanh Nguyen Duc, 
wrote:

> Technically csv doesn’t support multiple tabs so it is not able to achieve.
>
> Thanks and Best Regards,
>
> Thanh.
>
> On 9 Aug 2023, at 19:39, Aharonu  wrote:
>
> 
> Hi Evan Hisey,
>
> Thanks for your response.
>
> It is end user requested preferences. We don't need to avoid multiple
> files but segerate required data in one csv file with multiple tabs.
>
> Example,
> If I want to pull filesystem which are online and offline staus. We need
> both in one file cvs ox excel  but two different tabs.
>
> File1.cvs
>Tab1: Off_fs
>Tab2: On_fs
>
>
> On Wed, 9 Aug 2023, 17:57 Evan Hisey,  wrote:
>
>> Try starting with reviewing the problem the solution is trying to solve.
>> Why does it have too be two tabs? Is it a technical requirement or just a
>> preference? What will be consuming the data? Can it be used as two cvs?
>>
>> On Wednesday, August 9, 2023 at 6:56:50 AM UTC-5 Aharonu wrote:
>>
>>> Thank you. Even I am not much aware of Python coming in advance level.
>>>
>>> It looks like big task. I will wait anyone suggest us more better way
>>>
>>> On Wed, 9 Aug 2023, 17:15 Thanh Nguyen Duc, 
>>> wrote:
>>>
 Hope can help. I am not python programmer so code may not clean.
 from ansible.module_utils.basic import *
 import sys
 import os
 import csv
 import xlsxwriter
 import glob
 import codecs
 import pwd
 import grp
 def main():
 fields = {
 "csv_dir": {"required": True, "type": "str"},
 "output_xlsx_file": {"required": True, "type": "str"},
 "format_header": {"required": True, "type": "bool"},
 "format_error": {"required": False, "type": "list"},
 "format_correct": {"required": False, "type": "list"},
 "owner": {"required": False, "type": "str"},
 "group": {"required": False, "type": "str"},
 "split_data": {"required": False, "type": "bool"},
 "summary_csv_list": {"required": False, "type": "list", "default": []},
 }
 module = AnsibleModule(argument_spec=fields)
 wb = xlsxwriter.Workbook(module.params['output_xlsx_file'])
 format_header = wb.add_format()
 format_header.set_bold()
 format_header.set_bg_color('blue')
 format_header.set_font_color('white')
 f1 = wb.add_format({'bg_color': 'red', 'font_color': 'black', 'bold':
 True })
 f2 = wb.add_format({'bg_color': 'green', 'font_color': 'black', 'bold':
 True })
 f3 = wb.add_format({'border':1, 'border_color':'black', 'text_wrap':
 True})
 csv_dir = module.params['csv_dir']
 csv_file_list = sorted(glob.glob(csv_dir + '/*.csv'))
 summary_worksheets = []
 for summary_filename_csv in module.params['summary_csv_list']:
 summary_csv_file_path = os.path.join(csv_dir, summary_filename_csv)
 summary_sheet_title =
 os.path.splitext(os.path.basename(summary_csv_file_path))[0][0:31]
 summary_ws = wb.add_worksheet(summary_sheet_title)
 with codecs.open(summary_csv_file_path, 'r') as summary_csvfile:
 summary_table = csv.reader((l.replace('\0', '') for l in
 summary_csvfile))
 summary_num_row = 0
 summary_num_cols = 0
 summary_columns_width = []
 for summary_row in summary_table:
 if module.params['format_header'] and summary_num_row == 0:
 summary_ws.write_row(summary_num_row, 0, summary_row, format_header)
 else:
 modified_summary_row = []
 for item in summary_row:
 modified_summary_row.append(item)
 summary_ws.write_row(summary_num_row, 0, modified_summary_row, f3)
 summary_num_row += 1
 summary_num_cols = max(summary_num_cols, len(summary_row))
 summary_columns_width = [max(len(j), summary_columns_width[i] if
 len(summary_columns_width) > i else 1) for i, j in enumerate(summary_row)]
 # Simulate autofit column
 for i, j in enumerate(summary_columns_width):
 column_name = "%s:%s" % (chr(ord('A') + i), chr(ord('A') + i))
 summary_ws.set_column(column_name, j)
 summary_worksheets.append(summary_ws)
 summary_ws.autofit()
 summary_ws.conditional_format(
 'C2:C1',
 {'type': 'no_blanks', 'format': f2}
 )
 summary_ws.conditional_format(
 'D2:D1',
 {'type': 'no_blanks', 'format': f1}
 )
 # Move the summary sheets to the first position
 for summary_ws in summary_worksheets:
 summary_ws.set_first_sheet()
 for csv_file_path in csv_file_list:
 if os.path.basename(csv_file_path) in module.params['summary_csv_list']:
 continue
 sheet_title = os.path.splitext(os.path.basename(csv_file_path))[0][0:31]
 ws = wb.add_worksheet(sheet_title)
 with codecs.open(csv_file_path, 'r') as csvfile:
 table = csv.reader((l.replace('\0', '') for l in csvfile))
 num_row = 0
 num_cols = 0
 columns_width = []
 for row in table:
 if module.params['format_header'] and num_row == 0:
 ws.write_row(num_row, 0, r

Re: [ansible-project] Mail module - multiple tabs in csv file

2023-08-09 Thread Thanh Nguyen Duc
Technically csv doesn’t support multiple tabs so it is not able to achieve.Thanks and Best Regards,Thanh.On 9 Aug 2023, at 19:39, Aharonu  wrote:Hi Evan Hisey,Thanks for your response.It is end user requested preferences. We don't need to avoid multiple files but segerate required data in one csv file with multiple tabs.Example,If I want to pull filesystem which are online and offline staus. We need both in one file cvs ox excel  but two different tabs.File1.cvs   Tab1: Off_fs   Tab2: On_fsOn Wed, 9 Aug 2023, 17:57 Evan Hisey,  wrote:Try starting with reviewing the problem the solution is trying to solve. Why does it have too be two tabs? Is it a technical requirement or just a preference? What will be consuming the data? Can it be used as two cvs?On Wednesday, August 9, 2023 at 6:56:50 AM UTC-5 Aharonu wrote:Thank you. Even I am not much aware of Python coming in advance level.It looks like big task. I will wait anyone suggest us more better wayOn Wed, 9 Aug 2023, 17:15 Thanh Nguyen Duc,  wrote:Hope can help. I am not python programmer so code may not clean.from ansible.module_utils.basic import *import sysimport osimport csvimport xlsxwriterimport globimport codecsimport pwdimport grpdef main():fields = {"csv_dir": {"required": True, "type": "str"},"output_xlsx_file": {"required": True, "type": "str"},"format_header": {"required": True, "type": "bool"},"format_error": {"required": False, "type": "list"},"format_correct": {"required": False, "type": "list"},"owner": {"required": False, "type": "str"},"group": {"required": False, "type": "str"},"split_data": {"required": False, "type": "bool"},"summary_csv_list": {"required": False, "type": "list", "default": []},}module = AnsibleModule(argument_spec=fields)wb = xlsxwriter.Workbook(module.params['output_xlsx_file'])format_header = wb.add_format()format_header.set_bold()format_header.set_bg_color('blue')format_header.set_font_color('white')f1 = wb.add_format({'bg_color': 'red', 'font_color': 'black', 'bold': True })f2 = wb.add_format({'bg_color': 'green', 'font_color': 'black', 'bold': True })f3 = wb.add_format({'border':1, 'border_color':'black', 'text_wrap': True})csv_dir = module.params['csv_dir']csv_file_list = sorted(glob.glob(csv_dir + '/*.csv'))summary_worksheets = []for summary_filename_csv in module.params['summary_csv_list']:summary_csv_file_path = os.path.join(csv_dir, summary_filename_csv)summary_sheet_title = os.path.splitext(os.path.basename(summary_csv_file_path))[0][0:31]summary_ws = wb.add_worksheet(summary_sheet_title)with codecs.open(summary_csv_file_path, 'r') as summary_csvfile:summary_table = csv.reader((l.replace('\0', '') for l in summary_csvfile))summary_num_row = 0summary_num_cols = 0summary_columns_width = []for summary_row in summary_table:if module.params['format_header'] and summary_num_row == 0:summary_ws.write_row(summary_num_row, 0, summary_row, format_header)else:modified_summary_row = []for item in summary_row:modified_summary_row.append(item)summary_ws.write_row(summary_num_row, 0, modified_summary_row, f3)summary_num_row += 1summary_num_cols = max(summary_num_cols, len(summary_row))summary_columns_width = [max(len(j), summary_columns_width[i] if len(summary_columns_width) > i else 1) for i, j in enumerate(summary_row)]# Simulate autofit columnfor i, j in enumerate(summary_columns_width):column_name = "%s:%s" % (chr(ord('A') + i), chr(ord('A') + i))summary_ws.set_column(column_name, j)summary_worksheets.append(summary_ws)summary_ws.autofit()summary_ws.conditional_format('C2:C1',{'type': 'no_blanks', 'format': f2}) summary_ws.conditional_format('D2:D1',{'type': 'no_blanks', 'format': f1}) # Move the summary sheets to the first positionfor summary_ws in summary_worksheets:summary_ws.set_first_sheet()for csv_file_path in csv_file_list:if os.path.basename(csv_file_path) in module.params['summary_csv_list']:continuesheet_title = os.path.splitext(os.path.basename(csv_file_path))[0][0:31]ws = wb.add_worksheet(sheet_title)with codecs.open(csv_file_path, 'r') as csvfile:table = csv.reader((l.replace('\0', '') for l in csvfile))num_row = 0num_cols = 0columns_width = []for row in table:if module.params['format_header'] and num_row == 0:ws.write_row(num_row, 0, row, format_header)else:modified_row = []for item in row:if ',' in item and module.params['split_data']:split_data = item.split(',')trimmed_data = [value.strip() for value in split_data]modified_row.append('\n'.join(trimmed_data))else:modified_row.append(item)ws.write_row(num_row, 0, modified_row, f3)num_row += 1num_cols = max(num_cols, len(row))columns_width = [max(len(j), columns_width[i] if len(columns_width) > i else 1) for i, j in enumerate(row)]if module.params['format_error']:for i in module.params['format_error']:ws.conditional_format('A2:S1',{'type': 'text', 'criteria': 'containing', 'value': "%s" %i, 'format': f1}) if module.params['format_correct']:for i in module.params['format_correct']: ws.conditional_format('A

Re: [ansible-project] Mail module - multiple tabs in csv file

2023-08-09 Thread Aharonu
Hi Evan Hisey,

Thanks for your response.

It is end user requested preferences. We don't need to avoid multiple files
but segerate required data in one csv file with multiple tabs.

Example,
If I want to pull filesystem which are online and offline staus. We need
both in one file cvs ox excel  but two different tabs.

File1.cvs
   Tab1: Off_fs
   Tab2: On_fs


On Wed, 9 Aug 2023, 17:57 Evan Hisey,  wrote:

> Try starting with reviewing the problem the solution is trying to solve.
> Why does it have too be two tabs? Is it a technical requirement or just a
> preference? What will be consuming the data? Can it be used as two cvs?
>
> On Wednesday, August 9, 2023 at 6:56:50 AM UTC-5 Aharonu wrote:
>
>> Thank you. Even I am not much aware of Python coming in advance level.
>>
>> It looks like big task. I will wait anyone suggest us more better way
>>
>> On Wed, 9 Aug 2023, 17:15 Thanh Nguyen Duc,  wrote:
>>
>>> Hope can help. I am not python programmer so code may not clean.
>>> from ansible.module_utils.basic import *
>>> import sys
>>> import os
>>> import csv
>>> import xlsxwriter
>>> import glob
>>> import codecs
>>> import pwd
>>> import grp
>>> def main():
>>> fields = {
>>> "csv_dir": {"required": True, "type": "str"},
>>> "output_xlsx_file": {"required": True, "type": "str"},
>>> "format_header": {"required": True, "type": "bool"},
>>> "format_error": {"required": False, "type": "list"},
>>> "format_correct": {"required": False, "type": "list"},
>>> "owner": {"required": False, "type": "str"},
>>> "group": {"required": False, "type": "str"},
>>> "split_data": {"required": False, "type": "bool"},
>>> "summary_csv_list": {"required": False, "type": "list", "default": []},
>>> }
>>> module = AnsibleModule(argument_spec=fields)
>>> wb = xlsxwriter.Workbook(module.params['output_xlsx_file'])
>>> format_header = wb.add_format()
>>> format_header.set_bold()
>>> format_header.set_bg_color('blue')
>>> format_header.set_font_color('white')
>>> f1 = wb.add_format({'bg_color': 'red', 'font_color': 'black', 'bold':
>>> True })
>>> f2 = wb.add_format({'bg_color': 'green', 'font_color': 'black', 'bold':
>>> True })
>>> f3 = wb.add_format({'border':1, 'border_color':'black', 'text_wrap':
>>> True})
>>> csv_dir = module.params['csv_dir']
>>> csv_file_list = sorted(glob.glob(csv_dir + '/*.csv'))
>>> summary_worksheets = []
>>> for summary_filename_csv in module.params['summary_csv_list']:
>>> summary_csv_file_path = os.path.join(csv_dir, summary_filename_csv)
>>> summary_sheet_title =
>>> os.path.splitext(os.path.basename(summary_csv_file_path))[0][0:31]
>>> summary_ws = wb.add_worksheet(summary_sheet_title)
>>> with codecs.open(summary_csv_file_path, 'r') as summary_csvfile:
>>> summary_table = csv.reader((l.replace('\0', '') for l in
>>> summary_csvfile))
>>> summary_num_row = 0
>>> summary_num_cols = 0
>>> summary_columns_width = []
>>> for summary_row in summary_table:
>>> if module.params['format_header'] and summary_num_row == 0:
>>> summary_ws.write_row(summary_num_row, 0, summary_row, format_header)
>>> else:
>>> modified_summary_row = []
>>> for item in summary_row:
>>> modified_summary_row.append(item)
>>> summary_ws.write_row(summary_num_row, 0, modified_summary_row, f3)
>>> summary_num_row += 1
>>> summary_num_cols = max(summary_num_cols, len(summary_row))
>>> summary_columns_width = [max(len(j), summary_columns_width[i] if
>>> len(summary_columns_width) > i else 1) for i, j in enumerate(summary_row)]
>>> # Simulate autofit column
>>> for i, j in enumerate(summary_columns_width):
>>> column_name = "%s:%s" % (chr(ord('A') + i), chr(ord('A') + i))
>>> summary_ws.set_column(column_name, j)
>>> summary_worksheets.append(summary_ws)
>>> summary_ws.autofit()
>>> summary_ws.conditional_format(
>>> 'C2:C1',
>>> {'type': 'no_blanks', 'format': f2}
>>> )
>>> summary_ws.conditional_format(
>>> 'D2:D1',
>>> {'type': 'no_blanks', 'format': f1}
>>> )
>>> # Move the summary sheets to the first position
>>> for summary_ws in summary_worksheets:
>>> summary_ws.set_first_sheet()
>>> for csv_file_path in csv_file_list:
>>> if os.path.basename(csv_file_path) in module.params['summary_csv_list']:
>>> continue
>>> sheet_title = os.path.splitext(os.path.basename(csv_file_path))[0][0:31]
>>> ws = wb.add_worksheet(sheet_title)
>>> with codecs.open(csv_file_path, 'r') as csvfile:
>>> table = csv.reader((l.replace('\0', '') for l in csvfile))
>>> num_row = 0
>>> num_cols = 0
>>> columns_width = []
>>> for row in table:
>>> if module.params['format_header'] and num_row == 0:
>>> ws.write_row(num_row, 0, row, format_header)
>>> else:
>>> modified_row = []
>>> for item in row:
>>> if ',' in item and module.params['split_data']:
>>> split_data = item.split(',')
>>> trimmed_data = [value.strip() for value in split_data]
>>> modified_row.append('\n'.join(trimmed_data))
>>> else:
>>> modified_row.append(item)
>>> ws.write_row(num_row, 0, modified_row, f3)
>>> num_row += 1
>>> num_cols = max(num_cols, len(row))
>>> columns_width = [ma

Re: [ansible-project] Mail module - multiple tabs in csv file

2023-08-09 Thread Evan Hisey
Try starting with reviewing the problem the solution is trying to solve. 
Why does it have too be two tabs? Is it a technical requirement or just a 
preference? What will be consuming the data? Can it be used as two cvs?

On Wednesday, August 9, 2023 at 6:56:50 AM UTC-5 Aharonu wrote:

> Thank you. Even I am not much aware of Python coming in advance level.
>
> It looks like big task. I will wait anyone suggest us more better way
>
> On Wed, 9 Aug 2023, 17:15 Thanh Nguyen Duc,  wrote:
>
>> Hope can help. I am not python programmer so code may not clean.
>> from ansible.module_utils.basic import *
>> import sys
>> import os
>> import csv
>> import xlsxwriter
>> import glob
>> import codecs
>> import pwd
>> import grp
>> def main():
>> fields = {
>> "csv_dir": {"required": True, "type": "str"},
>> "output_xlsx_file": {"required": True, "type": "str"},
>> "format_header": {"required": True, "type": "bool"},
>> "format_error": {"required": False, "type": "list"},
>> "format_correct": {"required": False, "type": "list"},
>> "owner": {"required": False, "type": "str"},
>> "group": {"required": False, "type": "str"},
>> "split_data": {"required": False, "type": "bool"},
>> "summary_csv_list": {"required": False, "type": "list", "default": []},
>> }
>> module = AnsibleModule(argument_spec=fields)
>> wb = xlsxwriter.Workbook(module.params['output_xlsx_file'])
>> format_header = wb.add_format()
>> format_header.set_bold()
>> format_header.set_bg_color('blue')
>> format_header.set_font_color('white')
>> f1 = wb.add_format({'bg_color': 'red', 'font_color': 'black', 'bold': 
>> True })
>> f2 = wb.add_format({'bg_color': 'green', 'font_color': 'black', 'bold': 
>> True })
>> f3 = wb.add_format({'border':1, 'border_color':'black', 'text_wrap': 
>> True})
>> csv_dir = module.params['csv_dir']
>> csv_file_list = sorted(glob.glob(csv_dir + '/*.csv'))
>> summary_worksheets = []
>> for summary_filename_csv in module.params['summary_csv_list']:
>> summary_csv_file_path = os.path.join(csv_dir, summary_filename_csv)
>> summary_sheet_title = 
>> os.path.splitext(os.path.basename(summary_csv_file_path))[0][0:31]
>> summary_ws = wb.add_worksheet(summary_sheet_title)
>> with codecs.open(summary_csv_file_path, 'r') as summary_csvfile:
>> summary_table = csv.reader((l.replace('\0', '') for l in summary_csvfile))
>> summary_num_row = 0
>> summary_num_cols = 0
>> summary_columns_width = []
>> for summary_row in summary_table:
>> if module.params['format_header'] and summary_num_row == 0:
>> summary_ws.write_row(summary_num_row, 0, summary_row, format_header)
>> else:
>> modified_summary_row = []
>> for item in summary_row:
>> modified_summary_row.append(item)
>> summary_ws.write_row(summary_num_row, 0, modified_summary_row, f3)
>> summary_num_row += 1
>> summary_num_cols = max(summary_num_cols, len(summary_row))
>> summary_columns_width = [max(len(j), summary_columns_width[i] if 
>> len(summary_columns_width) > i else 1) for i, j in enumerate(summary_row)]
>> # Simulate autofit column
>> for i, j in enumerate(summary_columns_width):
>> column_name = "%s:%s" % (chr(ord('A') + i), chr(ord('A') + i))
>> summary_ws.set_column(column_name, j)
>> summary_worksheets.append(summary_ws)
>> summary_ws.autofit()
>> summary_ws.conditional_format(
>> 'C2:C1',
>> {'type': 'no_blanks', 'format': f2}
>> ) 
>> summary_ws.conditional_format(
>> 'D2:D1',
>> {'type': 'no_blanks', 'format': f1}
>> ) 
>> # Move the summary sheets to the first position
>> for summary_ws in summary_worksheets:
>> summary_ws.set_first_sheet()
>> for csv_file_path in csv_file_list:
>> if os.path.basename(csv_file_path) in module.params['summary_csv_list']:
>> continue
>> sheet_title = os.path.splitext(os.path.basename(csv_file_path))[0][0:31]
>> ws = wb.add_worksheet(sheet_title)
>> with codecs.open(csv_file_path, 'r') as csvfile:
>> table = csv.reader((l.replace('\0', '') for l in csvfile))
>> num_row = 0
>> num_cols = 0
>> columns_width = []
>> for row in table:
>> if module.params['format_header'] and num_row == 0:
>> ws.write_row(num_row, 0, row, format_header)
>> else:
>> modified_row = []
>> for item in row:
>> if ',' in item and module.params['split_data']:
>> split_data = item.split(',')
>> trimmed_data = [value.strip() for value in split_data]
>> modified_row.append('\n'.join(trimmed_data))
>> else:
>> modified_row.append(item)
>> ws.write_row(num_row, 0, modified_row, f3)
>> num_row += 1
>> num_cols = max(num_cols, len(row))
>> columns_width = [max(len(j), columns_width[i] if len(columns_width) > i 
>> else 1) for i, j in enumerate(row)]
>> if module.params['format_error']:
>> for i in module.params['format_error']:
>> ws.conditional_format('A2:S1',
>> {
>> 'type': 'text', 
>> 'criteria': 'containing', 
>> 'value': "%s" %i, 
>> 'format': f1
>> }
>> ) 
>> if module.params['format_correct']:
>> for i in module.params['format_correct']: 
>> ws.conditional_format('A2:S1',
>> {
>> 'type': 'text', 
>> 'criteria': 'containing', 
>> 'value': "%s" %i,
>> 'format

Re: [ansible-project] Mail module - multiple tabs in csv file

2023-08-09 Thread Aharonu
Thank you. Even I am not much aware of Python coming in advance level.

It looks like big task. I will wait anyone suggest us more better way

On Wed, 9 Aug 2023, 17:15 Thanh Nguyen Duc, 
wrote:

> Hope can help. I am not python programmer so code may not clean.
> from ansible.module_utils.basic import *
> import sys
> import os
> import csv
> import xlsxwriter
> import glob
> import codecs
> import pwd
> import grp
> def main():
> fields = {
> "csv_dir": {"required": True, "type": "str"},
> "output_xlsx_file": {"required": True, "type": "str"},
> "format_header": {"required": True, "type": "bool"},
> "format_error": {"required": False, "type": "list"},
> "format_correct": {"required": False, "type": "list"},
> "owner": {"required": False, "type": "str"},
> "group": {"required": False, "type": "str"},
> "split_data": {"required": False, "type": "bool"},
> "summary_csv_list": {"required": False, "type": "list", "default": []},
> }
> module = AnsibleModule(argument_spec=fields)
> wb = xlsxwriter.Workbook(module.params['output_xlsx_file'])
> format_header = wb.add_format()
> format_header.set_bold()
> format_header.set_bg_color('blue')
> format_header.set_font_color('white')
> f1 = wb.add_format({'bg_color': 'red', 'font_color': 'black', 'bold': True
> })
> f2 = wb.add_format({'bg_color': 'green', 'font_color': 'black', 'bold':
> True })
> f3 = wb.add_format({'border':1, 'border_color':'black', 'text_wrap': True})
> csv_dir = module.params['csv_dir']
> csv_file_list = sorted(glob.glob(csv_dir + '/*.csv'))
> summary_worksheets = []
> for summary_filename_csv in module.params['summary_csv_list']:
> summary_csv_file_path = os.path.join(csv_dir, summary_filename_csv)
> summary_sheet_title =
> os.path.splitext(os.path.basename(summary_csv_file_path))[0][0:31]
> summary_ws = wb.add_worksheet(summary_sheet_title)
> with codecs.open(summary_csv_file_path, 'r') as summary_csvfile:
> summary_table = csv.reader((l.replace('\0', '') for l in summary_csvfile))
> summary_num_row = 0
> summary_num_cols = 0
> summary_columns_width = []
> for summary_row in summary_table:
> if module.params['format_header'] and summary_num_row == 0:
> summary_ws.write_row(summary_num_row, 0, summary_row, format_header)
> else:
> modified_summary_row = []
> for item in summary_row:
> modified_summary_row.append(item)
> summary_ws.write_row(summary_num_row, 0, modified_summary_row, f3)
> summary_num_row += 1
> summary_num_cols = max(summary_num_cols, len(summary_row))
> summary_columns_width = [max(len(j), summary_columns_width[i] if
> len(summary_columns_width) > i else 1) for i, j in enumerate(summary_row)]
> # Simulate autofit column
> for i, j in enumerate(summary_columns_width):
> column_name = "%s:%s" % (chr(ord('A') + i), chr(ord('A') + i))
> summary_ws.set_column(column_name, j)
> summary_worksheets.append(summary_ws)
> summary_ws.autofit()
> summary_ws.conditional_format(
> 'C2:C1',
> {'type': 'no_blanks', 'format': f2}
> )
> summary_ws.conditional_format(
> 'D2:D1',
> {'type': 'no_blanks', 'format': f1}
> )
> # Move the summary sheets to the first position
> for summary_ws in summary_worksheets:
> summary_ws.set_first_sheet()
> for csv_file_path in csv_file_list:
> if os.path.basename(csv_file_path) in module.params['summary_csv_list']:
> continue
> sheet_title = os.path.splitext(os.path.basename(csv_file_path))[0][0:31]
> ws = wb.add_worksheet(sheet_title)
> with codecs.open(csv_file_path, 'r') as csvfile:
> table = csv.reader((l.replace('\0', '') for l in csvfile))
> num_row = 0
> num_cols = 0
> columns_width = []
> for row in table:
> if module.params['format_header'] and num_row == 0:
> ws.write_row(num_row, 0, row, format_header)
> else:
> modified_row = []
> for item in row:
> if ',' in item and module.params['split_data']:
> split_data = item.split(',')
> trimmed_data = [value.strip() for value in split_data]
> modified_row.append('\n'.join(trimmed_data))
> else:
> modified_row.append(item)
> ws.write_row(num_row, 0, modified_row, f3)
> num_row += 1
> num_cols = max(num_cols, len(row))
> columns_width = [max(len(j), columns_width[i] if len(columns_width) > i
> else 1) for i, j in enumerate(row)]
> if module.params['format_error']:
> for i in module.params['format_error']:
> ws.conditional_format('A2:S1',
> {
> 'type': 'text',
> 'criteria': 'containing',
> 'value': "%s" %i,
> 'format': f1
> }
> )
> if module.params['format_correct']:
> for i in module.params['format_correct']:
> ws.conditional_format('A2:S1',
> {
> 'type': 'text',
> 'criteria': 'containing',
> 'value': "%s" %i,
> 'format': f2
> }
> )
> if module.params['format_header']:
> ws.autofilter(0, 0, num_row-1, num_cols-1)
> ws.autofit()
> wb.close()
> # change ownership
> if module.params['owner'] and module.params['group']:
> uid = pwd.getpwnam(module.params['owner']).pw_uid
> gid = grp.getgrnam(module.params['group']).gr_gid
> os.chown(module.params['output_xlsx_file'], uid, gid)
> elif module.params['owner']:
> uid = pwd.getpwnam(module.params['owner'

Re: [ansible-project] Mail module - multiple tabs in csv file

2023-08-09 Thread Thanh Nguyen Duc
Hope can help. I am not python programmer so code may not clean.from ansible.module_utils.basic import *import sysimport osimport csvimport xlsxwriterimport globimport codecsimport pwdimport grpdef main():fields = {"csv_dir": {"required": True, "type": "str"},"output_xlsx_file": {"required": True, "type": "str"},"format_header": {"required": True, "type": "bool"},"format_error": {"required": False, "type": "list"},"format_correct": {"required": False, "type": "list"},"owner": {"required": False, "type": "str"},"group": {"required": False, "type": "str"},"split_data": {"required": False, "type": "bool"},"summary_csv_list": {"required": False, "type": "list", "default": []},}module = AnsibleModule(argument_spec=fields)wb = xlsxwriter.Workbook(module.params['output_xlsx_file'])format_header = wb.add_format()format_header.set_bold()format_header.set_bg_color('blue')format_header.set_font_color('white')f1 = wb.add_format({'bg_color': 'red', 'font_color': 'black', 'bold': True })f2 = wb.add_format({'bg_color': 'green', 'font_color': 'black', 'bold': True })f3 = wb.add_format({'border':1, 'border_color':'black', 'text_wrap': True})csv_dir = module.params['csv_dir']csv_file_list = sorted(glob.glob(csv_dir + '/*.csv'))summary_worksheets = []for summary_filename_csv in module.params['summary_csv_list']:summary_csv_file_path = os.path.join(csv_dir, summary_filename_csv)summary_sheet_title = os.path.splitext(os.path.basename(summary_csv_file_path))[0][0:31]summary_ws = wb.add_worksheet(summary_sheet_title)with codecs.open(summary_csv_file_path, 'r') as summary_csvfile:summary_table = csv.reader((l.replace('\0', '') for l in summary_csvfile))summary_num_row = 0summary_num_cols = 0summary_columns_width = []for summary_row in summary_table:if module.params['format_header'] and summary_num_row == 0:summary_ws.write_row(summary_num_row, 0, summary_row, format_header)else:modified_summary_row = []for item in summary_row:modified_summary_row.append(item)summary_ws.write_row(summary_num_row, 0, modified_summary_row, f3)summary_num_row += 1summary_num_cols = max(summary_num_cols, len(summary_row))summary_columns_width = [max(len(j), summary_columns_width[i] if len(summary_columns_width) > i else 1) for i, j in enumerate(summary_row)]# Simulate autofit columnfor i, j in enumerate(summary_columns_width):column_name = "%s:%s" % (chr(ord('A') + i), chr(ord('A') + i))summary_ws.set_column(column_name, j)summary_worksheets.append(summary_ws)summary_ws.autofit()summary_ws.conditional_format('C2:C1',{'type': 'no_blanks', 'format': f2}) summary_ws.conditional_format('D2:D1',{'type': 'no_blanks', 'format': f1}) # Move the summary sheets to the first positionfor summary_ws in summary_worksheets:summary_ws.set_first_sheet()for csv_file_path in csv_file_list:if os.path.basename(csv_file_path) in module.params['summary_csv_list']:continuesheet_title = os.path.splitext(os.path.basename(csv_file_path))[0][0:31]ws = wb.add_worksheet(sheet_title)with codecs.open(csv_file_path, 'r') as csvfile:table = csv.reader((l.replace('\0', '') for l in csvfile))num_row = 0num_cols = 0columns_width = []for row in table:if module.params['format_header'] and num_row == 0:ws.write_row(num_row, 0, row, format_header)else:modified_row = []for item in row:if ',' in item and module.params['split_data']:split_data = item.split(',')trimmed_data = [value.strip() for value in split_data]modified_row.append('\n'.join(trimmed_data))else:modified_row.append(item)ws.write_row(num_row, 0, modified_row, f3)num_row += 1num_cols = max(num_cols, len(row))columns_width = [max(len(j), columns_width[i] if len(columns_width) > i else 1) for i, j in enumerate(row)]if module.params['format_error']:for i in module.params['format_error']:ws.conditional_format('A2:S1',{'type': 'text', 'criteria': 'containing', 'value': "%s" %i, 'format': f1}) if module.params['format_correct']:for i in module.params['format_correct']: ws.conditional_format('A2:S1',{'type': 'text', 'criteria': 'containing', 'value': "%s" %i,'format': f2}) if module.params['format_header']:ws.autofilter(0, 0, num_row-1, num_cols-1)ws.autofit()wb.close()# change ownershipif module.params['owner'] and module.params['group']:uid = pwd.getpwnam(module.params['owner']).pw_uidgid = grp.getgrnam(module.params['group']).gr_gidos.chown(module.params['output_xlsx_file'], uid, gid)elif module.params['owner']:uid = pwd.getpwnam(module.params['owner']).pw_uidgid = grp.getgrnam(module.params['owner']).gr_gidos.chown(module.params['output_xlsx_file'], uid, gid)elif module.params['group']:uid = pwd.getpwnam(module.params['group']).pw_uidgid = grp.getgrnam(module.params['group']).gr_gidos.chown(module.params['output_xlsx_file'], uid, gid)response = {"result": "file %s created" % (module.params['output_xlsx_file'])}module.exit_json(changed=False, meta=response)if __name__ == '__main__':main()ansible localhost -m ncs_csvtoexcel \-a "csv_dir=/ancenter/opt-tasks/TESTPROD/Monthly/Windows/Compliance/2023-06-05 \output_xlsx_file

Re: [ansible-project] Mail module - multiple tabs in csv file

2023-08-09 Thread Aharonu
Hi  Thanh Nguyen Duc,

Thanks for quick response. May I get that reference details so I will give
try for my requirement.


On Wed, 9 Aug 2023, 16:29 Thanh Nguyen Duc, 
wrote:

> Csv i don’t think have multiple tabs. I have done with excel instead. You
> can use j2 template to create a csv then python to consolidate them to 1
> file.
> On 9 Aug 2023, at 17:55, Aharonu  wrote:
>
> 
> Hi Todd and Team,
>
> Could you please help one below query? Thank you.
>
> Example, I have  *file1.csv *creates throught mail module as
> mentionedbelow. I need to create 2 tabs (data-set1, data_set2)  in
> *file1.csv* and update required data. How can I deal with this?
>
> Thank you
>
>
> - name: Send csv file to the user  community.general.mail:host: port: 
> subject: Ansible-reportbody: Hello, this is an e-mailfrom: 
> j...@example.net (Jane Jolie)to: John Doe  attach: 
> ./*file1.csv*  delegate_to: localhost
>
> --
> 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/CANGEjuUuBxieKOifmcEqN9OY6Y%2BuqEdXyG2B%2BUv_eUk1FmiOVA%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/655EE3A2-3194-4219-B7D2-C7236C831F11%40gmail.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/CANGEjuWWTHkMSuTRJgKju70S9GOBSNok1oxndCkBr_aMa0vqGw%40mail.gmail.com.


Re: [ansible-project] Mail module - multiple tabs in csv file

2023-08-09 Thread Thanh Nguyen Duc
Csv i don’t think have multiple tabs. I have done with excel instead. You can use j2 template to create a csv then python to consolidate them to 1 file.On 9 Aug 2023, at 17:55, Aharonu  wrote:Hi Todd and Team,Could you please help one below query? Thank you.Example, I have  file1.csv creates throught mail module as mentionedbelow. I need to create 2 tabs (data-set1, data_set2)  in file1.csv and update required data. How can I deal with this?Thank you- name: Send csv file to the user
  community.general.mail:
host: 
port: 
subject: Ansible-report
body: Hello, this is an e-mail
from: j...@example.net (Jane Jolie)
to: John Doe  
attach: ./file1.csv
  delegate_to: localhost



-- 
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/CANGEjuUuBxieKOifmcEqN9OY6Y%2BuqEdXyG2B%2BUv_eUk1FmiOVA%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/655EE3A2-3194-4219-B7D2-C7236C831F11%40gmail.com.


[ansible-project] Mail module - multiple tabs in csv file

2023-08-09 Thread Aharonu
Hi Todd and Team,

Could you please help one below query? Thank you.

Example, I have  *file1.csv *creates throught mail module as mentionedbelow.
 I need to create 2 tabs (data-set1, data_set2)  in *file1.csv* and update
required data. How can I deal with this?

Thank you


- name: Send csv file to the user  community.general.mail:host:
 port: subject: Ansible-reportbody: Hello, this is an e-mail
 from: j...@example.net (Jane Jolie)to: John Doe 
attach: ./*file1.csv*  delegate_to: localhost

-- 
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/CANGEjuUuBxieKOifmcEqN9OY6Y%2BuqEdXyG2B%2BUv_eUk1FmiOVA%40mail.gmail.com.