I am trying to "include" a lot of other playbooks in a "playbook of 
playbooks" (I am aware, and have tried to use, the *import_playbook* and 
*include* modules to no avail), and am trying to apply the *ignore_errors: 
yes* to the imported/included playbook; since I am testing, and not all 
hosts are available, I would like to ignore the connection errors.

How can I write my main playbook (*all-programs.yml*) such that I can run 
through *playbooks/program[A-Z].yml* while ignoring errors should they 
occur?

Scenario:
I am running Ansible v. 2.7.10, with the following layout
.
├── group_vars
│   └── superGroup
│       ├── vars.yml
│       └── vault.yml
├── hosts
├── playbooks
│   ├── *all**-programs.**yml* # This is the playbook that I am struggling 
to write
│   ├── programA.yml
│   ├── programB.yml
│   ├── programC.yml
│   ...
│
├── roles
│   ├── programA
│   │   └── tasks
│   │       └── main.yml
│   ├── programB
│   │   └── tasks
│   │       └── main.yml
│   ├── programC
│   │   └── tasks
│   │       └── main.yml
... 



Here is what I have tried in *playbooks/all-programs.yml* so far (here, ... 
means the end of the YAML file):
# Attempt 1
---
- name: Run playbook for ProgramA
  import_playbook: "{{ playbook_dir }}/programX.yml"
  ignore_errors: yes 

- name: Run playbook for ProgramB
  import_playbook: "{{ playbook_dir }}/programY.yml"
  ignore_errors: yes 

...


######

# Attempt 2
---     
- name: Run playbook for ProgramA
  include: "{{ playbook_dir }}/programA.yml"

- name: Run playbook for ProgramB
  include: "{{ playbook_dir }}/programB.yml"
...


######

# Attempt 3
---     
- name: Run playbook for ProgramA
  hosts: localhost
  tasks:
    - include: "{{ playbook_dir }}/programA.yml"

- name: Run playbook for ProgramB
  hosts: localhost
  tasks:
    - include: "{{ playbook_dir }}/programB.yml"
...


######

# Attempt 4
---     
- name: Run all playbooks in a block
  hosts: localhost
  tasks:
      - name: Try ProgramA playbook
        block:
            - name: "playbook for programA"
              import_playbook: "{{ playbooks_dir }}/programA.yml"
        rescue:
            - debug:
                msg: "programA manipulation playbook failed"
        ignore_errors: yes

      - name: Try ProgramB playbook
        block:
            - name: "playbook for programB"
              import_playbook: "{{ playbooks_dir }}/programB.yml"
        rescue:
            - debug:
                msg: "no programB"
        ignore_errors: yes
...

Running with the following command line for each attempt above yields:
ansible-playbook --ask-vault-pass -i /path/to/hosts -e 
"playbook_dir=/path/to/playbooks" /path/to/playbooks/all-programs.yml

# Attempts 1-3:

PLAY [Run playbook for Program[A|B] *********************

TASK [(subtask of other_role)] **************************
fatal: [hostA-Z]: UNREACHABLE! => {"changed: false", ...}

NO MORE HOSTS LEFT **************************************
    to retry, use: --limit @/path/to/retry

#########################################################

# Attempt 4:

PLAY [Run all playbooks in a block] *********************

TASK [Gathering Facts] **********************************
ok: [localhost]

TASK [playbook for programA] ****************************
fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "", 
"module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the 
exact error", "rc": 0}
...ignoring

TASK [playbook for programB] ****************************
fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "", 
"module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the 
exact error", "rc": 0}
...ignoring

>From above, what might be the module failure being referred to?

General layout/schema of *playbooks/program[A-Z].yml* (here, ... means the 
end of the YAML file):
# playbooks/programA.yml
---
- name: Run role of ProgramX for required hosts
  hosts: hostA,hostC,groupB
  gather_facts: no
  strategy: free
  roles:
    - programX
...

# playbooks/programB.yml
---
- name: Run role of ProgramY for required hosts
  hosts: hostD,groupW
  gather_facts: no
  strategy: free
  roles:
    - programY
...

General layout/schema of *roles/program[A-Z]/tasks/main.yml* (here, ... 
means the end of the YAML file):
---
- name: Role for ProgramA
  include_role:
    name: other_role
  vars:
    var1: something
    var2: somethingElse
...

Thank you for taking your time to read this post.
Any assistance would be appreciated.

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-devel/f91a9399-71f2-4295-b325-29b1bbde9675%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to