Re: [ansible-project] Ansible ping report

2023-11-06 Thread Vladimir Botka
On Fri, 3 Nov 2023 08:40:19 -0700 (PDT)
Dimitri Yioulos  wrote:

> --- PING REPORT ---
> {% for pr in ping_result.results %}
> {{ pr.stdout_lines | first }}
> {{ pr.stdout_lines | last }}
> 
> {% endfor %}
> run_once: true
> delegate_to: localhost
> 
> That works fine. However, I want to use ansible.builtin.ping ...


Ignore unreachable hosts in a block

- block:
- ping:
  register: out
- set_fact:
unr: "{{ out.unreachable|d(false) }}"
  ignore_unreachable: true

and declare the dictionary

  h_unr: "{{ dict(ansible_play_hosts_all|
  zip(ansible_play_hosts_all|
  map('extract', hostvars, 'unr'))) }}"

For example, the below play

- hosts: test_01,test_05,test_06,test_07
  gather_facts: false

  vars:

h_unr: "{{ dict(ansible_play_hosts_all|
zip(ansible_play_hosts_all|
map('extract', hostvars, 'unr'))) }}"

  tasks:

- block:
- ping:
  register: out
- set_fact:
unr: "{{ out.unreachable|d(false) }}"
  ignore_unreachable: true

- debug:
var: h_unr
  run_once: true
  delegate_to: localhost

gives (abridged)

ok: [test_01 -> localhost] => 
  h_unr:
test_01: false
test_05: true
test_06: true
test_07: true

-- 
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/20231106205809.164c42fb%40gmail.com.


pgpEoJmLL1d_d.pgp
Description: OpenPGP digital signature


[ansible-project] New release: ansible-core 2.16.0 - All My Love

2023-11-06 Thread Matt Martz
Hi all- we're happy to announce the general release of:

ansible-core 2.16.0


How to get it
-

$ python3 -m pip install --user ansible-core==2.16.0

The release artifacts can be found here:

# Built Distribution: 2247142 bytes
# SHA256: 6b4870ac65b708953e1509b8ccca669731a17d2beadabd8208c9f90d189058ca
https://files.pythonhosted.org/packages/2f/ab/6357d8f3c17fec8c49c6119968292c14d3383c631bd900f6dc5593eb64a9/ansible_core-2.16.0-py3-none-any.whl
# Source Distribution: 3155083 bytes
# SHA256: b4a6c60fbc2f51e3ae68ec733c931ef957a04d7c8c92aa39242990b0f8adf149
https://files.pythonhosted.org/packages/6c/12/c0aec5705ee693986f62755fd3abbaf42ff3963980e42add4a2986ad79b0/ansible-core-2.16.0.tar.gz


What's new
--

This release is a major release. The full changelog can be found here:

https://github.com/ansible/ansible/blob/v2.16.0/changelogs/CHANGELOG-v2.16.rst

Important Changes:

* Drop Python 3.5 support for module execution
* Drop Python 3.9 support for controller
* Add Python 3.12 support
* Preserve display context when proxying display over the queue
* Update TaskExecutor to not unnecessarily establish persistent
ansible-connection when not needed


Schedule for future releases


The next release candidate is planned to be released on 27 November 2023.
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!

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


Re: [ansible-project] Issue escaping curly braces in template file

2023-11-06 Thread Dick Visser
If you need this a lot then you could even dedicate a filter to it.
For example, create a directory called 'filter_plugins' adjacent to your
playbook and then create a file called 'filters.py' that contains:

def embrace(string):
return '{' + string + '}'
class FilterModule(object):
def filters(self):
return {
'embrace': embrace
}


Now you can do:

activationID: "{{ lookup('ansible.builtin.env', 'QUALYS_ACTIVATIONID') |
embrace }}"
CustomerID: "{{ lookup('ansible.builtin.env', 'QUALYS_CUSTOMERID') |
embrace }}"

Dick

On Mon, 6 Nov 2023 at 16:04, matthew Higgs 
wrote:

> Hey.  I am having a bit of trouble trying to convert a jinja template
> because of the some issues escaping curly braces.  Consider this simple
> jinja template that is currently returning an error:
>
> activationID: {{{ lookup('ansible.builtin.env', 'QUALYS_ACTIVATIONID') }}}
> CustomerID: {{{ lookup('ansible.builtin.env', 'QUALYS_CUSTOMERID') }}}
>
> As you can see, there is an environment variable storing a string value
> that I need, but the final string that my playbook needs is that value
> surrounded by single curly brackets, eg:
>
> {34-34-456-34}
>
> I have tried various methods I found online to attempt to get ansible to
> properly convert the jinja template, including:
>
> Example 1:
> activationID: \{{{ lookup('ansible.builtin.env', 'QUALYS_ACTIVATIONID')
> }}\}
> CustomerID: \{{{ lookup('ansible.builtin.env', 'QUALYS_CUSTOMERID') }}\}
>
> Example 2:
> activationID: "{{{ lookup('ansible.builtin.env', 'QUALYS_ACTIVATIONID')
> }}}"
> CustomerID: "{{{ lookup('ansible.builtin.env', 'QUALYS_CUSTOMERID') }}}"
>
> Example 3:
> activationID: "\{{{ lookup('ansible.builtin.env', 'QUALYS_ACTIVATIONID')
> }}\}"
> CustomerID: "\{{{ lookup('ansible.builtin.env', 'QUALYS_CUSTOMERID') }}\}"
>
> But no matter what I try, I keep getting this error:
>
> The error was: . expected token ':', got '}
> I did notice some interesting output from ansible regarding how the
> template is being parsed as I ran the examples listed above.  For example,
> the output when I ran example 1:
> String: activationID: \\{{{ lookup('ansible.builtin.env',
> 'QUALYS_ACTIVATIONID') }}\\}\nCustomerID: \\{{{
> lookup('ansible.builtin.env', 'QUALYS_CUSTOMERID') }}\\}\n. expected token
> ':', got '}'"
> As you can see, "\" which I want to escape the outer most curly brace is
> itself being automatically escaped by ansible.   Same when I run example 3:
>
> "msg": "AnsibleError: template error while templating string: expected
> token ':', got '}'. String: activationID: \"\\{{{
> lookup('ansible.builtin.env', 'QUALYS_ACTIVATIONID') }}\\}\"\nCustomerID:
> \"\\{{{ lookup('ansible.builtin.env', 'QUALYS_CUSTOMERID') }}\\}\"\n.
> expected token ':', got '}'"
>
> I am at a loss as to what to do here.  Any help would be awesome.
>
> --
> 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/4c276d28-e411-4ac5-b6b3-df42165d50b8n%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/CAF8BbLbQC%3Dr0rTCZgHer6fDwVmcTN12Zx8qawvbv%2BQdfoUiDcw%40mail.gmail.com.


[ansible-project] New release: ansible-core 2.15.6

2023-11-06 Thread Matt Martz
Hi all- we're happy to announce the general release of:

ansible-core 2.15.6


How to get it
-

$ python3 -m pip install --user ansible-core==2.15.6

The release artifacts can be found here:

# Built Distribution: 2246779 bytes
# SHA256: fab3a5994482991274cae17500ca852007dbd76f564418f172f07cb00edbb293
https://files.pythonhosted.org/packages/85/3c/d18106a36722f7ae1790cc17472ef36c136ba510a57375ce6f56e65f61b1/ansible_core-2.15.6-py3-none-any.whl
# Source Distribution: 3154982 bytes
# SHA256: 351278fb8685fec1d645e2ddcfdca0c73456ff1db06426b86b6dd53774f7d7ba
https://files.pythonhosted.org/packages/13/06/5a513783d171467dba861f0341cda9f41044b9ba42462ac2b063da568550/ansible-core-2.15.6.tar.gz


What's new
--

This release is a maintenance release containing numerous bugfixes.

The full changelog can be found here:

https://github.com/ansible/ansible/blob/v2.15.6/changelogs/CHANGELOG-v2.15.rst


Schedule for future releases


The next release candidate is planned to be released on 27 November 2023.
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!

-- 
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/CAD8N0v-WHjqh03KuV8HKutwhZecxxmHXEpZsU_i-xEBNq_mxaQ%40mail.gmail.com.


Re: [ansible-project] Ansible ping report

2023-11-06 Thread Brian Coca
sorry, had only read the bottom, too used to people making that
mistake, but you did not.



-- 
--
Brian Coca

-- 
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/CACVha7drXWLCVJ5cL4qfPYy08FeMYk5RG_XhaeU_U690pF7P5w%40mail.gmail.com.


Re: [ansible-project] Ansible ping report

2023-11-06 Thread Dimitri Yioulos
Thanks, Brian. I suspected that was the case (I did read doc for the 
module), but was hoping there was some work-around. I'm still interested in 
trying to generate some type of report from Ansible ping. As you can see 
from the playbook I posted, that uses ICMP ping, which is not what I'm 
after.
On Monday, November 6, 2023 at 10:15:28 AM UTC-5 Brian Coca wrote:

> Not all modules return a stdout nor stdout_lines, ping is one of them,
> it returns 'data', check the RETURN DOCS for each module to know the
> structure of the registered var they return.
>
>
> -- 
> --
> Brian Coca
>
>

-- 
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/8a612b95-ce31-4d6d-b92e-5e4240fcbf3bn%40googlegroups.com.


Re: [ansible-project] Issue escaping curly braces in template file

2023-11-06 Thread Todd Lewis

Maybe try these expressions:

{{ '{' ~ lookup('ansible.builtin.env', 'QUALYS_ACTIVATIONID') ~ '}' }}
{{ '{' ~ lookup('ansible.builtin.env', 'QUALYS_CUSTOMERID') ~ '}' }}


On 11/4/23 10:35 PM, matthew Higgs wrote:
Hey.  I am having a bit of trouble trying to convert a jinja template 
because of the some issues escaping curly braces. Consider this simple 
jinja template that is currently returning an error:


activationID: {{{ lookup('ansible.builtin.env', 'QUALYS_ACTIVATIONID') }}}
CustomerID: {{{ lookup('ansible.builtin.env', 'QUALYS_CUSTOMERID') }}}

As you can see, there is an environment variable storing a string 
value that I need, but the final string that my playbook needs is that 
value surrounded by single curly brackets, eg:


{34-34-456-34}

I have tried various methods I found online to attempt to get ansible 
to properly convert the jinja template, including:


Example 1:
activationID: \{{{ lookup('ansible.builtin.env', 
'QUALYS_ACTIVATIONID') }}\}

CustomerID: \{{{ lookup('ansible.builtin.env', 'QUALYS_CUSTOMERID') }}\}

Example 2:
activationID: "{{{ lookup('ansible.builtin.env', 
'QUALYS_ACTIVATIONID') }}}"

CustomerID: "{{{ lookup('ansible.builtin.env', 'QUALYS_CUSTOMERID') }}}"

Example 3:
activationID: "\{{{ lookup('ansible.builtin.env', 
'QUALYS_ACTIVATIONID') }}\}"

CustomerID: "\{{{ lookup('ansible.builtin.env', 'QUALYS_CUSTOMERID') }}\}"

But no matter what I try, I keep getting this error:

The error was: . expected token ':', got '}
I did notice some interesting output from ansible regarding how the 
template is being parsed as I ran the examples listed above.  For 
example, the output when I ran example 1:
String: activationID: \\{{{ lookup('ansible.builtin.env', 
'QUALYS_ACTIVATIONID') }}\\}\nCustomerID: \\{{{ 
lookup('ansible.builtin.env', 'QUALYS_CUSTOMERID') }}\\}\n. expected 
token ':', got '}'"
As you can see, "\" which I want to escape the outer most curly brace 
is itself being automatically escaped by ansible.  Same when I run 
example 3:


"msg": "AnsibleError: template error while templating string: expected 
token ':', got '}'. String: activationID: \"\\{{{ 
lookup('ansible.builtin.env', 'QUALYS_ACTIVATIONID') 
}}\\}\"\nCustomerID: \"\\{{{ lookup('ansible.builtin.env', 
'QUALYS_CUSTOMERID') }}\\}\"\n. expected token ':', got '}'"


I am at a loss as to what to do here.  Any help would be awesome.
--
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/4c276d28-e411-4ac5-b6b3-df42165d50b8n%40googlegroups.com 
.


--
Todd

--
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/f5a486a9-c30f-4d82-ae14-647dab2d4e99%40gmail.com.


Re: [ansible-project] Ansible ping report

2023-11-06 Thread Brian Coca
Not all modules return a stdout nor stdout_lines, ping is one of them,
it returns 'data', check the RETURN DOCS for each module to know the
structure of the registered var they return.


-- 
--
Brian Coca

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


Re: [ansible-project] Run ansible tasks on hosts one-by-one

2023-11-06 Thread Brian Coca
roles can be in plays, plays cannot be in roles


-- 
--
Brian Coca

-- 
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/CACVha7dKrnZB0OXUY2-H6stQMko3D8NQB1tNVZdXjWkGYT4hqA%40mail.gmail.com.


[ansible-project] Ansible ping report

2023-11-06 Thread Dimitri Yioulos
Hi, All.

It's been some time since I used Ansible, and this list. I'm happy to be 
back using both.

I've created a [playbook to run pin, and create a report of output:

---
- name: check reachable hosts
hosts: dytest
gather_facts: no
tasks:
- name: Ping each host
ansible.builtin.command: ping -c1 {{ item }}
run_once: true
loop: "{{ ansible_play_hosts_all }}"
delegate_to: localhost
register: ping_result
failed_when: false

- name: How did we do?
ansible.builtin.debug:
msg: "{{ ping_result.results[0] }}"
run_once: true

- name: Format it a bit
# Note: the docs for 'copy' say don't do this, to use template instead,
# and there are reasons, but this suffices for posting purposes.
# The 'content:' below should be in your template.
ansible.builtin.copy:
dest: /home/deploy/ping.txt
content: |
--- PING REPORT ---
{% for pr in ping_result.results %}
{{ pr.stdout_lines | first }}
{{ pr.stdout_lines | last }}

{% endfor %}
run_once: true
delegate_to: localhost

That works fine. However, I want to use ansible.builtin.ping, not regular 
ping. When I substitute in ansible.builtin ping, I get the error:

fatal: [bed-test-9-dy1]: FAILED! => {"msg": "The task includes an option 
with an undefined variable. The error was: 'dict object' has no attribute 
'stdout'. 'dict object' has no attribute 'stdout'\n\nThe error appears to 
be in '/etc/ansible/playbooks/ping4.yml': line 15, column 7, but may\nbe 
elsewhere in the file depending on the exact syntax problem.\n\nThe 
offending line appears to be:\n\n\n- name: How did we do?\n 

What do I need to do to accomplish what I'm after?

Many thanks.

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


[ansible-project] Issue escaping curly braces in template file

2023-11-06 Thread matthew Higgs
Hey.  I am having a bit of trouble trying to convert a jinja template 
because of the some issues escaping curly braces.  Consider this simple 
jinja template that is currently returning an error:

activationID: {{{ lookup('ansible.builtin.env', 'QUALYS_ACTIVATIONID') }}}
CustomerID: {{{ lookup('ansible.builtin.env', 'QUALYS_CUSTOMERID') }}}

As you can see, there is an environment variable storing a string value 
that I need, but the final string that my playbook needs is that value 
surrounded by single curly brackets, eg:

{34-34-456-34}

I have tried various methods I found online to attempt to get ansible to 
properly convert the jinja template, including:

Example 1:
activationID: \{{{ lookup('ansible.builtin.env', 'QUALYS_ACTIVATIONID') }}\}
CustomerID: \{{{ lookup('ansible.builtin.env', 'QUALYS_CUSTOMERID') }}\}

Example 2:
activationID: "{{{ lookup('ansible.builtin.env', 'QUALYS_ACTIVATIONID') }}}"
CustomerID: "{{{ lookup('ansible.builtin.env', 'QUALYS_CUSTOMERID') }}}"

Example 3:
activationID: "\{{{ lookup('ansible.builtin.env', 'QUALYS_ACTIVATIONID') 
}}\}"
CustomerID: "\{{{ lookup('ansible.builtin.env', 'QUALYS_CUSTOMERID') }}\}"

But no matter what I try, I keep getting this error:

The error was: . expected token ':', got '}
I did notice some interesting output from ansible regarding how the 
template is being parsed as I ran the examples listed above.  For example, 
the output when I ran example 1:
String: activationID: \\{{{ lookup('ansible.builtin.env', 
'QUALYS_ACTIVATIONID') }}\\}\nCustomerID: \\{{{ 
lookup('ansible.builtin.env', 'QUALYS_CUSTOMERID') }}\\}\n. expected token 
':', got '}'"
As you can see, "\" which I want to escape the outer most curly brace is 
itself being automatically escaped by ansible.   Same when I run example 3:

"msg": "AnsibleError: template error while templating string: expected 
token ':', got '}'. String: activationID: \"\\{{{ 
lookup('ansible.builtin.env', 'QUALYS_ACTIVATIONID') }}\\}\"\nCustomerID: 
\"\\{{{ lookup('ansible.builtin.env', 'QUALYS_CUSTOMERID') }}\\}\"\n. 
expected token ':', got '}'"

I am at a loss as to what to do here.  Any help would be awesome.

-- 
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/4c276d28-e411-4ac5-b6b3-df42165d50b8n%40googlegroups.com.


Re: [ansible-project] Run ansible tasks on hosts one-by-one

2023-11-06 Thread Sameer Modak
so what i tried  is , I created another playbook and inside that mentioned 
serial which works fine with add_host . I am getting expected results but 
when i tried to add this code in my actual role. (I first test code in 
temporary playbook , so that i dont mess the role)

But when copy paste the code in my role here obviously structure is 
different,
main.yml-->zookeeper.yml(task yaml )--> imported playbook(new playbook as 
serial only works for plays).

code ,

this is zookeeper.yml which is a task list yaml, and not  a playbook

- name: Check who is existing zokeeper leader

  shell: 'echo stat | nc localhost 
"{{hostvars[inventory_hostname].zk_port}}" | grep Mode'

  register: zkmode



- name: Set service name as a fact  

  set_fact: 

service_name: "{{ zookeeper_service_name }}"


- name: Restart playbook

  import_playbook: Restart.yml



now when i run the role i get 

ERROR! this task 'import_playbook' has extra params, which is only allowed 
in the following modules: command, include, ansible.legacy.meta, 
ansible.legacy.set_fact, import_tasks, ansible.legacy.import_role, 
win_shell, group_by, win_command, ansible.builtin.set_fact, include_vars, 
ansible.builtin.shell, ansible.builtin.meta, ansible.legacy.group_by, 
ansible.legacy.win_command, set_fact, import_role, ansible.legacy.command, 
ansible.legacy.include_tasks, ansible.builtin.import_role, 
ansible.legacy.raw, meta, include_role, ansible.legacy.win_shell, 
include_tasks, ansible.builtin.script, add_host, ansible.legacy.add_host, 
ansible.builtin.include_tasks, script, ansible.builtin.include_vars, 
ansible.windows.win_command, ansible.builtin.add_host, 
ansible.legacy.include, ansible.legacy.include_role, ansible.legacy.shell, 
ansible.builtin.include_role, shell, ansible.legacy.script, 
ansible.builtin.win_shell, ansible.builtin.win_command, 
ansible.builtin.command, ansible.builtin.raw, raw, 
ansible.legacy.import_tasks, ansible.legacy.include_vars, 
ansible.builtin.group_by, ansible.windows.win_shell, 
ansible.builtin.include, ansible.builtin.import_tasks


The error appears to be in 
'/Users/sameer_modak/ansibledemo/prometheus/tasks/zookeeper_prometheus.yml': 
line 118, column 3, but may

be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

- name: Imporing Restartandcheck yaml

  ^ here


On Saturday, November 4, 2023 at 6:34:58 AM UTC+5:30 Todd Lewis wrote:

> - name: One host at a time
>   hosts: ducks_in_a_row
>   serial: 1
>   max_fail_percentage: 0
>   tasks:
> - task1
> - task2
> - task3
>
>
>
> On 11/3/23 3:57 PM, Sameer Modak wrote:
>
>
> How to acheive this then ?? 
> On Friday, November 3, 2023 at 11:36:48 PM UTC+5:30 Brian Coca wrote:
>
>> serial is a PLAY level keyword and what you want to use in this case, 
>> throttle will only control the forks/parallel jobs, not serialize a 
>> batch (this is what serial does). 
>>
>> -- 
>> -- 
>> Brian Coca 
>>
>> -- 
> 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/a628eae5-14f1-4e17-9425-2643282af93dn%40googlegroups.com
>  
> 
> .
>
>
> -- 
> Todd
>
>

-- 
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/6a3689e4-6441-4094-873a-e7d7d07f6ba6n%40googlegroups.com.


Re: [ansible-project] Run ansible tasks on hosts one-by-one

2023-11-06 Thread Sameer Modak
so what i tried  is , I created another playbook and inside that mentioned 
serial which works fine with add_host . I am getting expected results but 
when i tried to add this code in my actual role. (I first test code in 
temporary playbook , so that i dont mess the role)

But when copy paste the code in my role here obviously structure is 
different,
main.yml-->zookeeper.yml(task yaml )--> imported playbook(new playbook as 
serial only works for plays).

code ,

this is zookeeper.yml which is a task list yaml, and not  a playbook

- name: Check who is existing zokeeper leader

  shell: 'echo stat | nc localhost 
"{{hostvars[inventory_hostname].zk_port}}" | grep Mode'

  register: zkmode



- name: Set service name as a fact  

  set_fact: 

service_name: "{{ zookeeper_service_name }}"


- name: Restart playbook

  import_playbook: Restart.yml



now when i run the role i get 

ing: [en1dev1-main-kafka03.en1.whitepj.net]

ERROR! this task 'import_playbook' has extra params, which is only allowed 
in the following modules: command, include, ansible.legacy.meta, 
ansible.legacy.set_fact, import_tasks, ansible.legacy.import_role, 
win_shell, group_by, win_command, ansible.builtin.set_fact, include_vars, 
ansible.builtin.shell, ansible.builtin.meta, ansible.legacy.group_by, 
ansible.legacy.win_command, set_fact, import_role, ansible.legacy.command, 
ansible.legacy.include_tasks, ansible.builtin.import_role, 
ansible.legacy.raw, meta, include_role, ansible.legacy.win_shell, 
include_tasks, ansible.builtin.script, add_host, ansible.legacy.add_host, 
ansible.builtin.include_tasks, script, ansible.builtin.include_vars, 
ansible.windows.win_command, ansible.builtin.add_host, 
ansible.legacy.include, ansible.legacy.include_role, ansible.legacy.shell, 
ansible.builtin.include_role, shell, ansible.legacy.script, 
ansible.builtin.win_shell, ansible.builtin.win_command, 
ansible.builtin.command, ansible.builtin.raw, raw, 
ansible.legacy.import_tasks, ansible.legacy.include_vars, 
ansible.builtin.group_by, ansible.windows.win_shell, 
ansible.builtin.include, ansible.builtin.import_tasks


The error appears to be in 
'/Users/sameer_modak/ansibledemo/prometheus/tasks/zookeeper_prometheus.yml': 
line 118, column 3, but may

be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

- name: Imporing Restartandcheck yaml

  ^ here







On Saturday, November 4, 2023 at 6:34:58 AM UTC+5:30 Todd Lewis wrote:

> - name: One host at a time
>   hosts: ducks_in_a_row
>   serial: 1
>   max_fail_percentage: 0
>   tasks:
> - task1
> - task2
> - task3
>
>
>
> On 11/3/23 3:57 PM, Sameer Modak wrote:
>
>
> How to acheive this then ?? 
> On Friday, November 3, 2023 at 11:36:48 PM UTC+5:30 Brian Coca wrote:
>
>> serial is a PLAY level keyword and what you want to use in this case, 
>> throttle will only control the forks/parallel jobs, not serialize a 
>> batch (this is what serial does). 
>>
>> -- 
>> -- 
>> Brian Coca 
>>
>> -- 
> 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/a628eae5-14f1-4e17-9425-2643282af93dn%40googlegroups.com
>  
> 
> .
>
>
> -- 
> Todd
>
>

-- 
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/fcfdf2d9-5307-4584-b5a7-567aa17456c3n%40googlegroups.com.