On Tuesday, 27 March 2018 16.43.50 CEST z z wrote:
> 
> - name: Httpd running ?
>   shell: ps axo args |  grep httpd | grep -v grep 
>   register: apache
>   failed_when: false
>   ignore_errors: yes <*---- if this removed I get red error on non httpd 
> servers*
> 
> - name: Copy script
>   get_url:
>     url: "http://anotherscript.sh
>     dest: /tmp/anotherscript.sh
>     mode: 0755
>     owner: root
>     group: root
>     force: yes
>   when: apache.rc == 0
> 
> What I want is some thing along those lines
> 
> when apache.rc == 0
>    do  url; dest; mode; owner etc
>    done
> when apache.rc != 0 
>     next
> 
> If I put " ignore_errors: yes " then it ignore apache.rc and do every 
> thing(url, dest, mod etc) on a given server regardless it has httpd running 
> or not.
> If I remove " ignore_errors: yes " then it starts bringing red font errors on 
> all the servers where httpd is not running.

I can't confirm that with 2.4 or 2.5

---
- hosts: localhost
  tasks:
    - shell: ps axo args |  grep httpd | grep -v grep 
      register: apache
      failed_when: false


$ ansible-playbook test.yml

TASK [command] ************************************************************
changed: [localhost] => {
    "changed": true,
    "cmd": "ps axo args | grep httpd | grep -v grep",
    "delta": "0:00:00.045870",
    "end": "2018-03-27 17:03:16.817237",
    "failed_when_result": false,
    "rc": 1,
    "start": "2018-03-27 17:03:16.771367"
}

MSG:

non-zero return code


TASK [debug] **************************************************************
ok: [localhost] => {
    "apache": {
        "changed": true,
        "cmd": "ps axo args | grep httpd | grep -v grep",
        "delta": "0:00:00.045870",
        "end": "2018-03-27 17:03:16.817237",
        "failed": false,
        "failed_when_result": false,
        "msg": "non-zero return code",
        "rc": 1,
        "start": "2018-03-27 17:03:16.771367",
        "stderr": "",
        "stderr_lines": [],
        "stdout": "",
        "stdout_lines": []
    }
}

PLAY RECAP ****************************************************************
localhost                  : ok=2    changed=1    unreachable=0    failed=0   



-- 
Kai Stian Olstad

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/9013469.UOMualXdvV%40x1.
For more options, visit https://groups.google.com/d/optout.

Reply via email to