Re: [ansible-project] Question about source files in an Ansible Collection

2023-06-07 Thread Vladimir Botka
On Wed, 7 Jun 2023 11:16:35 -0700 (PDT)
"lift...@gmail.com"  wrote:

> - ansible.builtin.yum:
> name: files/mysql-connector-j-8.0.33-1.el7.noarch.rpm
> 
> I even tried to copy the file locally using the copy module with the 
> remote_src flag set to true, but I get the same "file not found" error.  

Absolute path on the remote host is required

  if spec.endswith('.rpm') or '://' in spec:
  if '://' not in spec and not os.path.exists(spec):
  res['msg'] += "No RPM file matching '%s' found on system" % spec

https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/yum.py#L1040


-- 
Vladimir Botka

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/20230608021025.7d1fb785%40gmail.com.


pgpMLO71NKjcL.pgp
Description: OpenPGP digital signature


[ansible-project] Question about source files in an Ansible Collection

2023-06-07 Thread lift...@gmail.com
I have a collection that I've built with numerous roles in it.  Under one 
of the roles, I have a files folder with some files in it used during the 
role execution.  However, I have a situation where 2 of these files keep 
erroring out saying that the source isn't found.

For example, I have one file that I use the unarchive module to extract it, 
and it works:

- name: Branding | Extract the jar file
  ansible.builtin.unarchive:
src: files/tsose.jar
dest: /var/tmp/guacbranding

But when I try to install an RPM that is located in the same files folder, 
I get an error stating that the source file is not found:

- name: Install Latest RHEL 7 MySQL Connector
  ansible.builtin.yum:
name: files/mysql-connector-j-8.0.33-1.el7.noarch.rpm
state: present
disable_gpg_check: true

I even tried to copy the file locally using the copy module with the 
remote_src flag set to true, but I get the same "file not found" error.  
And when I check the tar file that is created and I upload to our 
automation hub, the files are there under files.

Any ideas?

Thanks,
Harry

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/f181c8b6-30b7-4074-b88f-3e8d2210ef78n%40googlegroups.com.


Re: [ansible-project] terminate the whole play if any fatal errors on any host occurs

2023-06-07 Thread Edvinas Kairys
Last update (I think).

So i managed to clarify the situation. Seems that the problem occurs only
when i'm using roles with block/rescue options. Without it everything works
smooth.

For example:


*Roles Playbook without block/rescue:- hosts: TEONET01A,TEONET01B*





* gather_facts: false any_errors_fatal: True roles: - test Roles task
(block commented): --- # - name: Run test pbook # block: - assert: that: -
ansible_hostname == 'TEONET01A' - debug: msg: In role # rescue: # - debug:
# msg: Rescue Runs as expected and play exists after fatal error in
assert:root@PCEDVKAIL3:/etc/ansible# ansible-playbook playbook.ymlPLAY
[TEONET01A,TEONET01B]
***
TASK [test : assert]
*
[WARNING]: ansible-pylibssh not installed, falling back to paramiko ok:
[10.8.250.46] => { "changed": false, "msg": "All assertions passed" }
[WARNING]: ansible-pylibssh not installed, falling back to paramiko fatal:
[10.8.250.47]: FAILED! => { "assertion": "ansible_hostname == 'TEONET01A'",
"changed": false, "evaluated_to": false, "msg": "Assertion failed" } NO
MORE HOSTS LEFT
***
PLAY RECAP
***
10.8.250.46 : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0
ignored=0 10.8.250.47 : ok=0 changed=0 unreachable=0 failed=1 skipped=0
rescued=0 ignored=0 Now how it works with block/rescue - seems like bugsame
playbook:- hosts: TEONET01A,TEONET01B gather_facts: false any_errors_fatal:
True roles: - test Roles (block uncommented): --- - name: Run test pbook
block: - assert: that: - ansible_hostname == 'TEONET01A' - debug: msg: In
role rescue: - debug: msg: Rescue Runs as not expected and play continues
with other host even the host assert fails: root@PCEDVKAIL3:/etc/ansible#
ansible-playbook playbook.yml PLAY [TEONET01A,TEONET01B]
***
TASK [test : assert]
*
[WARNING]: ansible-pylibssh not installed, falling back to paramiko ok:
[10.8.250.46] => { "changed": false, "msg": "All assertions passed" }
[WARNING]: ansible-pylibssh not installed, falling back to paramiko fatal:
[10.8.250.47]: FAILED! => { "assertion": "ansible_hostname == 'TEONET01A'",
"changed": false, "evaluated_to": false, "msg": "Assertion failed" } TASK
[test : debug]
**
ok: [10.8.250.46] => { "msg": "In role" } TASK [test : debug]
**
ok: [10.8.250.47] => { "msg": "Rescue" } PLAY RECAP
***
10.8.250.46 : ok=2 changed=0 unreachable=0 failed=0 skipped=0 rescued=0
ignored=0 10.8.250.47 : ok=1 changed=0 unreachable=0 failed=0 skipped=0
rescued=1 ignored=0 *





On Tue, Jun 6, 2023 at 4:29 PM Edvinas Kairys 
wrote:

> checked again, problem with serial 1 is that it doesn't run tasks in
> parallel.
>
> so then i have same playbook which is not in roles it runs like this:
>
>
>
>
> *TASK 

Re: [ansible-project] File system monitoring

2023-06-07 Thread Dick Visser
On Wed, 7 Jun 2023 at 10:07, Ebrahim Kutty  wrote:

> Hi,
>
> I want to configure to check the file system free space available
> everyday and send mail if it is more than 80% . I tried with the below YAML
> code, but didn't  work.
>

"Didn't work" is very little information.
But, even with the right amount of information I think it would be best to
not (ab)use ansible for this task and instead use a dedicated monitoring
system





>---
>- name: Check Filesystem Usage
>  hosts: 10.190.0.36
>  gather_facts: true
>  tasks:
> - name: Get Filesystem Facts
>   shell: "df -h /|grep -v Filesystem|awk '{print $4}'|cut -d G -f1"
>   register: df_out
> - debug:
> var: df_out.stdout_lines[1] | !int
>
> - name: Send Email Notification
>   command: echo "Filesystem Usage is above the threshold." | mail
> -s "Filesystem Alert" ebrahimkal...@gmail.com
>   when: df_out.stdout_lines[1] | int  > 30  # Specify the
> threshold percentage here
> ...
>
>
> Regards,
> Ebrahim
>
> --
> 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/d50c6b7f-fc9a-429d-a40e-e3cac43184efn%40googlegroups.com
> 
> .
>
-- 
Sent from Gmail Mobile

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAF8BbLZgL9_o7-CpC-D-U_n9CTouTA7pZaaociogbNUOE%2BJqdw%40mail.gmail.com.


[ansible-project] File system monitoring

2023-06-07 Thread Ebrahim Kutty
Hi,

I want to configure to check the file system free space available  everyday 
and send mail if it is more than 80% . I tried with the below YAML code, 
but didn't  work.

   ---
   - name: Check Filesystem Usage
 hosts: 10.190.0.36
 gather_facts: true
 tasks:
- name: Get Filesystem Facts
  shell: "df -h /|grep -v Filesystem|awk '{print $4}'|cut -d G -f1"
  register: df_out
- debug:
var: df_out.stdout_lines[1] | !int

- name: Send Email Notification
  command: echo "Filesystem Usage is above the threshold." | mail 
-s "Filesystem Alert" ebrahimkal...@gmail.com
  when: df_out.stdout_lines[1] | int  > 30  # Specify the threshold 
percentage here
...
 

Regards,
Ebrahim

-- 
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/d50c6b7f-fc9a-429d-a40e-e3cac43184efn%40googlegroups.com.


Re: [ansible-project] Check_mode is not working for vmware_rest api module

2023-06-07 Thread Deepak B K
Hi  Andrew, 

Please find the details . 
COMPONENT NAME

vmware.vmware_rest.vcenter_vm:
ANSIBLE VERSION
config file = None configured module search path = 
['/home/deep/.ansible/plugins/modules', 
'/usr/share/ansible/plugins/modules'] ansible python module location = 
/home/deep/.local/lib/python3.10/site-packages/ansible ansible collection 
location = /home/deep/.ansible/collections:/usr/share/ansible/collections 
executable location = /home/deep/.local/bin/ansible python version = 3.10.6 
(main, May 29 2023, 11:10:38) [GCC 11.3.0] jinja version = 3.1.2 libyaml = 
True 
COLLECTION VERSION

`# /home/deep/.ansible/collections/ansible_collections
Collection Version

vmware.vmware_rest 2.3.1
# CONFIGURATION  ```paste below 
OS / ENVIRONMENT

PRETTY_NAME="Ubuntu 22.04.1 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.1 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/;
SUPPORT_URL="https://help.ubuntu.com/;
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/;
PRIVACY_POLICY_URL="
https://www.ubuntu.com/legal/terms-and-policies/privacy-policy;
UBUNTU_CODENAME=jammy
STEPS TO REPRODUCE

Try to dry run the playbook delvm.yml
ansible-playbook delvm.yml --check -i inventory --limit test-host

--

   - 
   
   name: Delete VM
   hosts: all
   gather_facts: false
   become: false
   
   tasks:
   
Lookup VM ID from the vm name

- name: "Lookup VM: {{ vm_name }}" vmware.vmware_rest.vcenter_vm_info: 
vcenter_hostname: "{{ vcenter.hostname }}" vcenter_username: "{{ 
vcenter.username }}" vcenter_password: "{{ vcenter.password }}" 
vcenter_validate_certs: "{{ vcenter.validate_certs }}" filter_names: "{{ 
vm_name }}" register: lookup_result delegate_to: "{{ delegation_host }}" 
Collect VM ID from the vm name
- name: "Collect information about VM: {{ vm_name }}" 
vmware.vmware_rest.vcenter_vm_info: vcenter_hostname: "{{ vcenter.hostname 
}}" vcenter_username: "{{ vcenter.username }}" vcenter_password: "{{ 
vcenter.password }}" vcenter_validate_certs: "{{ vcenter.validate_certs }}" 
vm: "{{ lookup_result.value[0].vm }}" register: vm_info delegate_to: "{{ 
delegation_host }}" 
@title  Delete VM@comment 
 This task deletes the VM from the vcenter

- name: "Delete VM: {{ vm_name }}" vmware.vmware_rest.vcenter_vm: 
vcenter_hostname: "{{ vcenter.hostname }}" vcenter_username: "{{ 
vcenter.username }}" vcenter_password: "{{ vcenter.password }}" 
vcenter_validate_certs: "{{ vcenter.validate_certs }}" state: absent vm: 
"{{ vm_info.id }}" delegate_to: "{{ delegation_host }}" 
 # 
EXPECTED RESULTS excepted result its should not remove the vm and just dry 
run the steps but unfortunately with option --check it is removing the vm 
in vcenter not performing dry run. 

On Tuesday, June 6, 2023 at 6:36:46 PM UTC+5:30 Andrew Latham wrote:

> Deepak
>
> You may get more responses if you provide actual examples in the form of 
> playbook/task/role you are attempting. Please also identify the Ansible 
> version and the VMWare module/version you are using.
>
> On Tue, Jun 6, 2023 at 2:42 AM Deepak B K  wrote:
>
>> We are testing  ansible vmware module were we wanted to test in dry run 
>> mode the playbooks which has vmware rest modules used and we see the 
>> --check  or check_mode = yes is not working  its deletes the vm  where its 
>> except to just dry run the task . Just wanted to understand the dryrun 
>> works for vmware modules?
>>
>> Thanks 
>> Deepak Kumar
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Ansible Project" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to ansible-proje...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/4a885873-a30e-48c9-bb69-8f93975e924bn%40googlegroups.com
>>  
>> 
>> .
>>
>
>
> -- 
> - Andrew "lathama" Latham -
>

-- 
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/ddb61e8e-f7c8-4d84-a70f-30313df0b9d1n%40googlegroups.com.