ERROR! 'retries' is not a valid attribute for a TaskInclude

151 views
Skip to first unread message

Shifa Shaikh

unread,
May 20, 2020, 10:48:56 PM5/20/20
to Ansible Project
My requirement is to run the script stop-all as many times (5 retries) until the output of ps -fu user1 |wc -l becomes less than 2.

I wrote the below ansible playbook for the same:

cat stop.yml

  - hosts: dest_nodes
    tasks
:
     
- name: Start service
        include_tasks
: "{{ playbook-dir }}/inner.yml"
        retries
: 5
        delay
: 4
       
until: stopprocesscount.stdout is version('2', '<')

cat inner.yml

- name: Start service
  shell
: ~/stop-all
 
register: stopprocess


- name: Start service
  shell
: ps -fu user1 |wc -l
 
register: stopprocesscount


However, I get the below error running the playbook.

ERROR! 'retries' is not a valid attribute for a TaskInclude


The error appears to be in '/app/playbook/stop.yml': line 19, column 9, but may
be elsewhere
in the file depending on the exact syntax problem.


The offending line appears to be:


- name: Start service
 
^ here

Can you please suggest?

Stefan Hornburg (Racke)

unread,
May 21, 2020, 1:19:39 AM5/21/20
to ansible...@googlegroups.com
On 5/21/20 4:48 AM, Shifa Shaikh wrote:
> My requirement is to run the script stop-all as many times (5 retries) until the output of ps -fu user1 |wc -l becomes
> less than 2.
>
> I wrote the below ansible playbook for the same:
>
> cat stop.yml
>
> |
>   -hosts:dest_nodes
>     tasks:
>       -name:Startservice
>         include_tasks:"{{ playbook-dir }}/inner.yml"
>         retries:5
>         delay:4
>         until:stopprocesscount.stdout isversion('2','<')
> |
>
> cat inner.yml
>
> |
> -name:Startservice
>   shell:~/stop-all
>   register:stopprocess
>
>
> -name:Startservice
>   shell:ps -fu user1 |wc -l
>   register:stopprocesscount
> |
>
>
> However, I get the below error running the playbook.
>
> |
> ERROR!'retries'isnota valid attribute fora TaskInclude
>
>
> Theerror appears to be in'/app/playbook/stop.yml':line 19,column 9,but may
> be elsewhere inthe file depending on the exact syntax problem.
>
>
> Theoffending line appears to be:
>
>
> -name:Startservice
>   ^here
> |
>
> Can you please suggest?

The question is why you don't use one of the various mechanism on a Linux system to ensure
that a process is started or stopped.

Regards
Racke

>
> --
> 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 <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/8a89923a-eebf-433a-92d7-4098c7af2b03%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/8a89923a-eebf-433a-92d7-4098c7af2b03%40googlegroups.com?utm_medium=email&utm_source=footer>.


--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.

signature.asc

Shifa Shaikh

unread,
May 21, 2020, 8:45:59 AM5/21/20
to Ansible Project
@Stefan Our service involves a set of processes thus, the start script invokes those several processes and hence the need to count the number of processes using `wc -l` to determine if the service (not the process) is running or not. 

Dick Visser

unread,
May 21, 2020, 8:52:04 AM5/21/20
to ansible...@googlegroups.com
This sounds all very much like pushing a round peg into a square hole. 
I would focus on fine tuning some systemd unit files and their dependencies, instead of the carpet stopping/starting approach.


--
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/4a53d56d-3e8a-4929-9cbd-b4b3d67b8237%40googlegroups.com.
--
Sent from a mobile device - please excuse the brevity, spelling and punctuation.

Suneel Gali

unread,
May 21, 2020, 12:44:02 PM5/21/20
to ansible...@googlegroups.com
>>>> " ERROR! 'retries' is not a valid attribute for a TaskInclude"
Can we use "until" against include_tasks? 

Its like we are inserting the same tasks multiple times in the  playbook ...  

Can you use until condition with the actual task itself and check?

Reply all
Reply to author
Forward
0 new messages