[ansible-project] Re: lineinfile is skipped if one of the task ignored

2021-07-19 Thread Hanumantha Reddy Basireddy
Hello All,

Any leads

On Monday, July 19, 2021 at 1:17:35 PM UTC+5:30 Hanumantha Reddy Basireddy 
wrote:

> Hi All,
> I have a playbook as follows:
>
> ---
> - hosts: all
>   gather_facts: no
>   ignore_unreachable: true
>
>   tasks:
>   - command: "{{ item }}"
> loop:
>   - "ls" 
>   - "df -h"
> register: files
> ignore_errors: true
>   - name: delegate
> command: ls
> register: files2
> delegate_to: "{{item}}"
> ignore_errors: true
> with_items:
>   - "{{groups['test_servers1']}}"
>   - lineinfile:
>   line: "{{ item.stdout }}"
>   path: /tmp/list.log
>   create: yes
> when:
>   - item.changed is defined
>   - item.changed
> loop: "{{ files.results + 
>   files2.results}}"
>
> TEST1: my inventory looks as follows:
> 192.168.153.31
>  #[test_servers1] 
>
> output:
> TASK [command] 
>  changed: 
> [192.168.153.31] => (item=ls) changed: [192.168.153.31] => (item=df -h) 
> TASK [delegate] 
> * 
> fatal: [192.168.153.31]: FAILED! => {"msg": "'dict object' has no attribute 
> 'test_servers1'"} ...ignoring TASK [lineinfile] 
> * skipping: 
> [192.168.153.31] 
>
> TEST2: inventory as follows:
> 192.168.153.31
> [test_servers1] 
>
> Output:
> TASK [command] 
> ** 
> changed: [192.168.153.31] => (item=ls) changed: [192.168.153.31] => 
> (item=df -h) 
>  TASK [delegate] 
>  
>  TASK [debug] 
> * ok: 
> [192.168.153.31] => { "files2": { "changed": false, "results": [], 
> "skipped": true, "skipped_reason": "No items in the list" } } 
> TASK [lineinfile] ** 
> changed: [192.168.153.31] => (item={'start': '2021-07-18 02:11:13.080046', 
> 'stderr': '', 'rc': 0, 'invocation': {'module_args': {'_raw_par.. 
>
> *Question1*: In TEST1 since inventory doesn't contain test_servers1 group, 
> so task is ignored. but why lineinfile is skipped eventhought file 
> variable contain results?
>
> *Question2*: In TEST2, my delegate task contains only one command i.e., 
> *ls *why file2 has results? As per my knowledge when looping through 
> multiple commands only register variable contains results.
>
> *Question3*: In lineinfile module, Is it possible to check files2 contains 
> results and 
> if yes to check files2.results is not empty then only loop through it 
> otherwise skip it?
> someone please clarify my doubts. Thanks in Advance.
>
> Thanks,
> BHR.
>

-- 
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/59f5bef0-4ed9-48de-85fb-289e03967658n%40googlegroups.com.


[ansible-project] New releases: ansible-core 2.11.3, ansible-base 2.10.12, ansible 2.9.24

2021-07-19 Thread Rick Elrod
Hi all- we're happy to announce the general release of:

- ansible-core 2.11.3
- ansible-base 2.10.12
- ansible 2.9.24

How to get it
-

$ pip install ansible-core==2.11.3 --user
or
$ pip install ansible-base==2.10.12 --user
or
$ pip install ansible==2.9.24 --user

The tar.gz of the release can be found here:

* ansible-core 2.11.3
  
https://pypi.python.org/packages/source/a/ansible-core/ansible-core-2.11.3.tar.gz
  SHA256: 0ced1b4f67197edb27b50934c95d4cb644c6d635d72c7f826c4425dfe4537674

* ansible-base 2.10.12
  
https://pypi.python.org/packages/source/a/ansible-base/ansible-base-2.10.12.tar.gz
  SHA256: a96556e2d239f9283e15654d40c1aa86682a4e7b43f50b5ff022bc8e42b69878

* ansible 2.9.24
  https://releases.ansible.com/ansible/ansible-2.9.24.tar.gz
  SHA256: 0c2f53b7be73ddc3423d9658fcd19079897d5b1fc533c4ad550db58b179aeb8a


What's new
--

This release is a maintenance release containing numerous bugfixes. The full
changelog is at:

* ansible-core 2.11.3
  
https://github.com/ansible/ansible/blob/stable-2.11/changelogs/CHANGELOG-v2.11.rst

* ansible-base 2.10.12
  
https://github.com/ansible/ansible/blob/stable-2.10/changelogs/CHANGELOG-v2.10.rst

* ansible 2.9.24
  
https://github.com/ansible/ansible/blob/stable-2.9/changelogs/CHANGELOG-v2.9.rst


What's the schedule for future maintenance releases?


The next batch of release candidates is planned to be released 3 weeks from
today, on 9 August 2021. The next general availability release will be one week
after.


Porting Help


If you discover any errors or if any of your working playbooks break when you
upgrade, please use the following link to report the regression:

  https://github.com/ansible/ansible/issues/new/choose

In your issue, be sure to mention the version that works and the one that
doesn't.

Thanks!

-Rick Elrod

-- 
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/CAMuUyjSKkFvi78SpwX9QOTb%3DG96wjY9ticxtnB2LCQQmSFJmxg%40mail.gmail.com.


[ansible-project] how to get values from dict in template with for loop ?

2021-07-19 Thread Eric Chang

I have two dict file like

teams.yml
{
  "teams": [{"gid": 10125,"location": ["hq"],"name": "aa","users": 
["chenhu","chouf"]},
{"gid": 10126,"location": ["hq"],"name": "ac","users": 
["guoj","yangc"]} ]

}

users.yml
{
"users": [{"name": "changc","uid": 2},
{"name": "changb","uid": 20001} ]
}

I want to generate a file using template  , so I start with two seperate 
for loop for test
{% for i in users %}
{{ i.uid }} {{ i.name }}
{% endfor %}

{% for j in teams %}
{{ j.users }} {{ j.name }}
{% endfor %}

and ansible run with errors
*AnsibleUndefinedVariable: 'dict object' has no attribute 'users'*

but teams dictonary did have users attr , why ansible can not get the value 
??

so if I want to create a for loop in jinja2 template the condition is
when user's name show in teams then write down user's name and teams name
how do I do it ?
{% for i in users %}
 {for j in teams %}
  {if i.name in j.users %}
{{ i.name }}_{{ j.name }}
{% endif %}
{% endfor %}
{% endfor %}

that's my first thought , but I have no idea how to do now ..
any suggestions ??

-- 
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/19478e2b-4b74-4dc2-8755-5a55ae4a8c4bn%40googlegroups.com.


Re: [ansible-project] Stouck in Ansible

2021-07-19 Thread Dan Linder
Abdul,

If you're stuck as to how to ask the question, the StackOverflow "How do I 
ask a good question?" is a good reference. 

https://stackoverflow.com/help/how-to-ask

Dan

On Monday, July 19, 2021 at 2:51:02 AM UTC-5 dick@geant.org wrote:

> This is almost zero information to help you with. Please provide more 
> details. 
>
> On Mon, 19 Jul 2021 at 09:15, Abdul Waheed Khan  
> wrote:
>
>> Hi everyone,
>> i am new in this forum . i am configuring ansible (tyk-ansible) but stuck 
>> in .
>> please help me.
>> Regards,
>>  Abdul waheed 
>>
>> -- 
>> 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/c4d51001-d4b2-43d0-99cd-b8ed5459d12an%40googlegroups.com
>>  
>> 
>> .
>>
> -- 
> Sent from a mobile device - please excuse the brevity, spelling and 
> punctuation.
>

-- 
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/b3e4e763-64e8-45e6-b307-1f579a302389n%40googlegroups.com.


[ansible-project] Re: list all files in directory and copy all content.

2021-07-19 Thread Vincent Nambatac
I suspect what would be the right value in this unarchived_list.files[0] to 
input to copy all directories. When I tried another number like 1,2,3 only 
those another directories there are being copied .



On Tuesday, July 20, 2021 at 9:42:49 AM UTC+8 Vincent Nambatac wrote:

>
> Hi there , I want to ask what approach  I will do If I want to copy all 
> content in an unzip files. I unzip the files and list all directories. the 
> problem is I want to copy all files inside the directory but only 1 content 
> being copied. Can somebody how to it. Here is my code.
>
>
>   - name: "Unzip zookeeper package {{ zookeeper_installation_package }} "
> unarchive:
>   src: "{{ zookeeper_install_package_host_folder }}/{{ 
> zookeeper_installation_package }}"
>   dest: "{{ zookeeper_install_package_host_folder }}"
>   list_files: yes
>   remote_src: yes
> register: unarchived_list
>
>
>   - name: Removing {{ zookeeper_install_package_host_folder }}/{{ 
> zookeeper_installation_package }}
> file:
>   path: "{{ zookeeper_install_package_host_folder }}/{{ 
> zookeeper_installation_package }}"
>   state: absent
>
>   - name: Create symbolic link {{ zookeeper_sym_link }} for 
> {{zookeeper_install_package_host_folder}}/{{ unarchived_list.files[0] }}
> file:
>   src: "{{zookeeper_install_package_host_folder}}/{{ 
> unarchived_list.files[0] }}"
>   dest: "/opt/zookeeper"
>   state: link
>
>
> --- in the Create symbolic link Task I want to copy all content in my 
> unzip file which is zookeeper.tar and make a symbolic link with it using 
> all the content to /opt/zookeeper directory.
>
>
>
> [image: Screenshot from 2021-07-20 09-40-10.png]
>
> In this case , only docs directory being copied . instead all the content .
>
>
> Best regards,
> Vincent
>

-- 
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/1e9184e7-d974-4f21-a4dc-cda25f7d55dfn%40googlegroups.com.


[ansible-project] list all files in directory and copy all content.

2021-07-19 Thread Vincent Nambatac

Hi there , I want to ask what approach  I will do If I want to copy all 
content in an unzip files. I unzip the files and list all directories. the 
problem is I want to copy all files inside the directory but only 1 content 
being copied. Can somebody how to it. Here is my code.


  - name: "Unzip zookeeper package {{ zookeeper_installation_package }} "
unarchive:
  src: "{{ zookeeper_install_package_host_folder }}/{{ 
zookeeper_installation_package }}"
  dest: "{{ zookeeper_install_package_host_folder }}"
  list_files: yes
  remote_src: yes
register: unarchived_list


  - name: Removing {{ zookeeper_install_package_host_folder }}/{{ 
zookeeper_installation_package }}
file:
  path: "{{ zookeeper_install_package_host_folder }}/{{ 
zookeeper_installation_package }}"
  state: absent

  - name: Create symbolic link {{ zookeeper_sym_link }} for 
{{zookeeper_install_package_host_folder}}/{{ unarchived_list.files[0] }}
file:
  src: "{{zookeeper_install_package_host_folder}}/{{ 
unarchived_list.files[0] }}"
  dest: "/opt/zookeeper"
  state: link


--- in the Create symbolic link Task I want to copy all content in my unzip 
file which is zookeeper.tar and make a symbolic link with it using all the 
content to /opt/zookeeper directory.



[image: Screenshot from 2021-07-20 09-40-10.png]

In this case , only docs directory being copied . instead all the content .


Best regards,
Vincent

-- 
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/088038cc-1ce9-4c35-bf67-44aadb2376cen%40googlegroups.com.


Re: [ansible-project] question about tags

2021-07-19 Thread Doug Hunley
I find
https://docs.ansible.com/ansible/2.8/reference_appendices/special_variables.html
to be a gold mine for these kinds of things. Just match it with whatever
version of Ansible you're supporting.

On Mon, Jul 19, 2021 at 3:56 PM John Petro  wrote:

> oh, that is cool.  I didn't know about that one.  Thanks, I will check it
> out.
>

-- 
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/CAMiM3L1N8j3GhE_eAq6k16WuYwv%3DyiwiuAU9Pkdg-j8E-PDtEQ%40mail.gmail.com.


Re: [ansible-project] question about tags

2021-07-19 Thread John Petro
oh, that is cool.  I didn't know about that one.  Thanks, I will check it
out.

--John

On Mon, Jul 19, 2021 at 3:48 PM Doug Hunley 
wrote:

> You could inspect ansible_run_tags and see if those three tags are not in
> it.
>
> On Mon, Jul 19, 2021 at 3:44 PM John Petro  wrote:
>
>> I have a bit of a problem, and was wondering if anyone has ever done
>> something like this.  I have a playbook I am working on, where it updates
>> firewalld rules for some kubernetes clusters we have.  Rather than have a
>> playbook per cluster, we elected to use tags, one for prod, one for
>> nonprod, and one for beta.
>>
>> What I am trying to do, is have task, that if it isn't one of the three
>> mentioned tags ( Prod, Non-Prod, Beta) then it executes, basically
>> outputting a debug message that the only accepted tags are those three.  Is
>> there a way to say something like "If tags !=[Prod,Non-Prod,Beta] then
>> output text"?
>>
>> I was fairly sure that at some point I saw that there was a way to do
>> that, and I can't seem to find the example anymore so any help anyone can
>> offer wold be greatly appreciated.
>>
>> --John
>>
> --
> 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/CAMiM3L3uLqzCzrrtoOwhs8e2_sk2wUmXt%3DSrPjJEnWy%2BHN%2B%2B7w%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/CAPAjob80eSNVG5d3XG3vmFKr5LtPE%2B4k0pH8mAHqye3eZyefPw%40mail.gmail.com.


Re: [ansible-project] question about tags

2021-07-19 Thread Doug Hunley
You could inspect ansible_run_tags and see if those three tags are not in
it.

On Mon, Jul 19, 2021 at 3:44 PM John Petro  wrote:

> I have a bit of a problem, and was wondering if anyone has ever done
> something like this.  I have a playbook I am working on, where it updates
> firewalld rules for some kubernetes clusters we have.  Rather than have a
> playbook per cluster, we elected to use tags, one for prod, one for
> nonprod, and one for beta.
>
> What I am trying to do, is have task, that if it isn't one of the three
> mentioned tags ( Prod, Non-Prod, Beta) then it executes, basically
> outputting a debug message that the only accepted tags are those three.  Is
> there a way to say something like "If tags !=[Prod,Non-Prod,Beta] then
> output text"?
>
> I was fairly sure that at some point I saw that there was a way to do
> that, and I can't seem to find the example anymore so any help anyone can
> offer wold be greatly appreciated.
>
> --John
>

-- 
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/CAMiM3L3uLqzCzrrtoOwhs8e2_sk2wUmXt%3DSrPjJEnWy%2BHN%2B%2B7w%40mail.gmail.com.


[ansible-project] question about tags

2021-07-19 Thread John Petro
I have a bit of a problem, and was wondering if anyone has ever done
something like this.  I have a playbook I am working on, where it updates
firewalld rules for some kubernetes clusters we have.  Rather than have a
playbook per cluster, we elected to use tags, one for prod, one for
nonprod, and one for beta.

What I am trying to do, is have task, that if it isn't one of the three
mentioned tags ( Prod, Non-Prod, Beta) then it executes, basically
outputting a debug message that the only accepted tags are those three.  Is
there a way to say something like "If tags !=[Prod,Non-Prod,Beta] then
output text"?

I was fairly sure that at some point I saw that there was a way to do that,
and I can't seem to find the example anymore so any help anyone can offer
wold be greatly appreciated.

--John

-- 
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/CAPAjob_d_GP-4z6E5LvcU3z78ezrXB_P%3DsDgg2WEUrtdEpa95A%40mail.gmail.com.


Re: [ansible-project] Ansible network module ios_config dont work on my fs S3260switch

2021-07-19 Thread Antony Stone
On Monday 19 July 2021 at 19:13:21, Tiago Oliveira wrote:

> I actually dont have anything of the module done.

So, how are you getting the error "this operation requires privilege 
escalation"?

> I wanted to see the ios_config module and how it was done so i could have
> an ideia of what to do.. but i cant find the documentation and the how to
> do that module.

There may only be source code.  Not everyone documents the development of 
things like this in sufficient detail that other developers can understand the 
design process.

> About the fs.com switches, the one i am trying to use is a lot similar to
> cisco ios, with small diferences. for example

Sorry, but phrases like "small differences" and "for example" are not enough to 
write software.  You need specifications - you need definite documentation 
about 
_exactly_ how things need to be done.

> you do enable and then config and not config terminal, and i dont know if that
> changes something for the module not working, because if i use ios_command
> module and write all the commands: enable,config i can use this commands
> inside fs switch config without problems..

Start with something simple.

Make sure you can do one specific, simple command manually, and then get an 
ansible module to do it for you.  If you need escalated privileges, well, put 
that in (I assume you already know how to do that in ansible).

Then, once you have something simple working, build up to the real goal of the 
full configuration you are trying to achieve.

If you need further help from the list, though, I really think you need to 
provide some details about what you are doing, what the errors are, and what 
the fs.com documentation says needs to be done to make something work.


Antony.

-- 
You can tell that the day just isn't going right when you find yourself using 
the telephone before the toilet.

   Please reply to the list;
 please *don't* CC me.


Re: [ansible-project] Ansible network module ios_config dont work on my fs S3260switch

2021-07-19 Thread Tiago Oliveira
I actually dont have anything of the module done.

I wanted to see the ios_config module and how it was done so i could have 
an ideia of what to do.. but i cant find the documentation and the how to 
do that module.

About the fs.com switches, the one i am trying to use is a lot similar to 
cisco ios, with small diferences. for example you do enable and then config 
and not config terminal, and i dont know if that changes something for the 
module not working, because if i use ios_command module and write all the 
commands: enable,config i can use this commands inside fs switch config 
without problems..

Tiago

A segunda-feira, 19 de julho de 2021 à(s) 18:02:30 UTC+1, Antony Stone 
escreveu:

> On Monday 19 July 2021 at 18:52:32, Mythicale wrote:
>
> > my boss ask me to try to "create" a module like ios_config but that 
> fs.com
> > accept it.
> > 
> > Right now when i try to use it on fs switch, it says that this operation
> > requires privilege escalation, if i use ios_command the operations works.
>
> Perhaps you could show us what you currently have for this new module, so 
> we 
> have an understanding of what commands you are trying to run which require 
> special privileges.
>
> Also, any documentation you can point us to, for those of us not 
> intimately 
> familiar with fs.com switches and their remote management capabilities, 
> would 
> probably help.
>
>
> Antony.
>
> -- 
> The difference between theory and practice is that in theory there is no 
> difference, whereas in practice there is.
>
> Please reply to the list;
> please *don't* CC me.
>

-- 
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/66108e41-f9e7-438a-aec9-da7ee52b2200n%40googlegroups.com.


Re: [ansible-project] Ansible network module ios_config dont work on my fs S3260switch

2021-07-19 Thread Antony Stone
On Monday 19 July 2021 at 18:52:32, Mythicale wrote:

> my boss ask me to try to "create" a module like ios_config but that fs.com
> accept it.
> 
> Right now when i try to use it on fs switch, it says that this operation
> requires privilege escalation, if i use ios_command the operations works.

Perhaps you could show us what you currently have for this new module, so we 
have an understanding of what commands you are trying to run which require 
special privileges.

Also, any documentation you can point us to, for those of us not intimately 
familiar with fs.com switches and their remote management capabilities, would 
probably help.


Antony.

-- 
The difference between theory and practice is that in theory there is no 
difference, whereas in practice there is.

   Please reply to the list;
 please *don't* CC me.


[ansible-project] Ansible network module ios_config dont work on my fs S3260switch

2021-07-19 Thread Mythicale
Hello!

I finishing my course beeing an intern on a company, and my project is 
switch automation with ansible.

With the cisco switch its not hard, but fs.com switches although they are 
similar to cisco, dont accept some modules, like, ios_config, and my boss 
ask me to try to "create" a module like ios_config but that fs.com accept 
it.

Right now when i try to use it on fs switch, it says that this operation 
requires privilege escalation, if i use ios_command the operations works. 
Can somoene help me on how to use ios_config like a template and change it 
to be able to use on fs.com???

Best Regards,
Tiago Oliveira

-- 
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/35283208-f030-4060-872b-9e7f6f5d39dbn%40googlegroups.com.


[ansible-project] Ansible play freezes and never completes after copying part of the files using synchronize module

2021-07-19 Thread Mohtashim S


Below is my playbook that helps transfer a set of files from remote source 
to local directory.

- name: "Play 1.5"

  hosts: "{{ groups['dest_nodes'] | default(groups['all']) }}"

  serial: 1

  gather_facts: false

 

  vars:

ansible_host_key_checking: false

ansible_ssh_extra_args: -o StrictHostKeyChecking=no  -o 
ConnectionAttempts=5

 

  tasks:

 

- find:

paths: "{{ homedir.stdout_lines[0] | trim }}"

recurse: no

file_type: any

hidden: yes

patterns:

  - "(.*txt)$"

  - "(.*sh.*)$"

  - "(.*bash.*)$"

  - "(.*ksh.*)$"

  - "(.*profile.*)$"

use_regex: yes

  register: to_copy

 

 

- debug:

msg: "FOUNDDD {{ item.path}}"

  with_items: "{{ to_copy.files }}"

 

 

- name: Copying from "{{ inventory_hostname }}" to this ansible 
server.

  synchronize:

src: "{{ item.path }}"

dest: "{{ playbook_dir }}/homedirbackup/{{ inventory_hostname 
}}/{{ dtime }}/"

mode: pull

copy_links: yes

  with_items:

- "{{ to_copy.files }}"

It copies a few files from remote to local directory "{{ playbook_dir 
}}/homedirbackup/{{ inventory_hostname }}/{{ dtime }}/" but then freezes 
midway and times-out i.e does not complete the transfer of all the files.

The below output shows that it transferred two 
files /opt/oracle/checkservice.sh & /opt/oracle/stopservice.sh but froze / 
never returned while trying to 
transfer .profile.bak.configurevwsapi.2018.11.08-21.07.49

 ESTABLISH LOCAL CONNECTION FOR USER: localuser

 EXEC /bin/sh -c '/usr/bin/python2 && sleep 0'

changed: [remotehost35] => (item={u'uid': 60014, u'woth': False, 
u'mtime': 1603787134.107684, u'inode': 100717, u'isgid': False, u'size': 
651, u'isuid': False, u'isreg': True, u'gid': 63855, u'ischr': False, 
u'wusr': True, u'xoth': False, u'rusr': True, u'nlink': 1, u'issock': 
False, u'rgrp': True, u'path': u'/opt/oracle/checkservice.sh', u'xusr': 
True, u'atime': 1626695687.6682055, u'isdir': False, u'ctime': 
1603787134.108393, u'isblk': False, u'wgrp': False, u'xgrp': False, u'dev': 
1301375156245, u'roth': True, u'isfifo': False, u'mode': u'0744', u'islnk': 
False}) => {

"changed": true, 

"cmd": "/bin/rsync --delay-updates -F --compress --copy-links --archive 
--rsh=/usr/share/centrifydc/bin/ssh -S none -o StrictHostKeyChecking=no -o 
UserKnownHostsFile=/dev/null --out-format=<>%i %n%L 
oracle@remotehost35:/opt/oracle/checkservice.sh 
/web/playbooks/automation/aesstartup/homedirbackup/remotehost35/2021-07-19-08-10-07/",
 


"invocation": {

"module_args": {

"_local_rsync_path": "rsync", 

"_substitute_controller": false, 

"archive": true, 

"checksum": false, 

"compress": true, 

"copy_links": true, 

"delete": false, 

"dest": 
"/web/playbooks/automation/aesstartup/homedirbackup/remotehost35/2021-07-19-08-10-07/",
 


"dest_port": null, 

"dirs": false, 

"existing_only": false, 

"group": null, 

"links": null, 

"mode": "pull", 

"owner": null, 

"partial": false, 

"perms": null, 

"private_key": null, 

"recursive": null, 

"rsync_opts": null, 

"rsync_path": null, 

"rsync_timeout": 0, 

"set_remote_user": true, 

"src": "oracle@remotehost35:/opt/oracle/checkservice.sh", 

"ssh_args": null, 

"times": null, 

"verify_host": false

}

}, 

"item": {

"atime": 1626695687.6682055, 

"ctime": 1603787134.108393, 

"dev": 1301375156245, 

"gid": 63855, 

"inode": 100717, 

"isblk": false, 

"ischr": false, 

"isdir": false, 

"isfifo": false, 

"isgid": false, 

"islnk": false, 

"isreg": true, 

"issock": false, 

"isuid": false, 

"mode": "0744", 

"mtime": 1603787134.107684, 

"nlink": 1, 

"path": "/opt/oracle/checkservice.sh", 

"rgrp": true, 

"roth": true, 

"rusr": true, 

"size": 651, 

"uid": 60014, 

"wgrp": false, 

"woth": false, 

"wusr": true, 

"xgrp": false, 

"xoth": false, 

"xusr": true

}, 

"msg": ">f+ checkservice.sh\n", 

"rc": 0, 

"stdout_lines": [

">f+ checkservice.sh"

]

}

Using module file 
/usr/lib/python2.7/site-packages/ansible/modules/files/synchronize.py

 ESTABLISH LOCAL CONNECTION FOR USER: localuser

 EXEC /bin/sh -c '/usr/bin/python2 && sleep 0'

changed: [remotehost35] => (item={u'uid': 60014, 

Re: [ansible-project] Stouck in Ansible

2021-07-19 Thread Dick Visser
This is almost zero information to help you with. Please provide more
details.

On Mon, 19 Jul 2021 at 09:15, Abdul Waheed Khan 
wrote:

> Hi everyone,
> i am new in this forum . i am configuring ansible (tyk-ansible) but stuck
> in .
> please help me.
> Regards,
>  Abdul waheed
>
> --
> 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/c4d51001-d4b2-43d0-99cd-b8ed5459d12an%40googlegroups.com
> 
> .
>
-- 
Sent from a mobile device - please excuse the brevity, spelling and
punctuation.

-- 
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/CAL8fbwMxhe2DtBJ4%3DCufdxH9qNeasjRJoXC%2BbMTkKqve%2BJqu8A%40mail.gmail.com.


[ansible-project] lineinfile is skipped if one of the task ignored

2021-07-19 Thread Hanumantha Reddy Basireddy
Hi All,
I have a playbook as follows:

---
- hosts: all
  gather_facts: no
  ignore_unreachable: true

  tasks:
  - command: "{{ item }}"
loop:
  - "ls" 
  - "df -h"
register: files
ignore_errors: true
  - name: delegate
command: ls
register: files2
delegate_to: "{{item}}"
ignore_errors: true
with_items:
  - "{{groups['test_servers1']}}"
  - lineinfile:
  line: "{{ item.stdout }}"
  path: /tmp/list.log
  create: yes
when:
  - item.changed is defined
  - item.changed
loop: "{{ files.results + 
  files2.results}}"

TEST1: my inventory looks as follows:
192.168.153.31
 #[test_servers1] 

output:
TASK [command] 
 changed: 
[192.168.153.31] => (item=ls) changed: [192.168.153.31] => (item=df -h) 
TASK [delegate] 
* 
fatal: [192.168.153.31]: FAILED! => {"msg": "'dict object' has no attribute 
'test_servers1'"} ...ignoring TASK [lineinfile] 
* skipping: 
[192.168.153.31] 

TEST2: inventory as follows:
192.168.153.31
[test_servers1] 

Output:
TASK [command] 
** 
changed: [192.168.153.31] => (item=ls) changed: [192.168.153.31] => 
(item=df -h) 
 TASK [delegate] 
 
 TASK [debug] 
* ok: 
[192.168.153.31] => { "files2": { "changed": false, "results": [], 
"skipped": true, "skipped_reason": "No items in the list" } } 
TASK [lineinfile] ** 
changed: [192.168.153.31] => (item={'start': '2021-07-18 02:11:13.080046', 
'stderr': '', 'rc': 0, 'invocation': {'module_args': {'_raw_par.. 

*Question1*: In TEST1 since inventory doesn't contain test_servers1 group, 
so task is ignored. but why lineinfile is skipped eventhought file variable 
contain results?

*Question2*: In TEST2, my delegate task contains only one command i.e., 
*ls *why file2 has results? As per my knowledge when looping through 
multiple commands only register variable contains results.

*Question3*: In lineinfile module, Is it possible to check files2 contains 
results and 
if yes to check files2.results is not empty then only loop through it 
otherwise skip it?
someone please clarify my doubts. Thanks in Advance.

Thanks,
BHR.

-- 
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/728d1870-987f-4c11-8c18-b703c1a1ec16n%40googlegroups.com.


[ansible-project] Stouck in Ansible

2021-07-19 Thread Abdul Waheed Khan
Hi everyone,
i am new in this forum . i am configuring ansible (tyk-ansible) but stuck 
in .
please help me.
Regards,
 Abdul waheed 

-- 
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/c4d51001-d4b2-43d0-99cd-b8ed5459d12an%40googlegroups.com.