OSC / ood-ansible

An ansible role for Open Ondemand
MIT License
30 stars 31 forks source link

No file was found when using first_found #151

Open simonLeary42 opened 2 years ago

simonLeary42 commented 2 years ago

my host is a proxmox ubuntu jammy LXC. The only edit I made to this role was enabling build from source.

$ cat hosts:

[ood]
123.456.789.123

$ cat custom_ood.yml

---
- hosts: ood
  roles:
  - role: ood-ansible-2.0.6

$ ansible-playbook custom_ood.yml

TASK [ood-ansible-2.0.6 : include distribution variables] **********************************************************************************
fatal: [ood]: FAILED! => {"msg": "No file was found when using first_found."}
simonLeary42 commented 2 years ago

$ cat roles/ood-ansible-2.0.6/tasks/main.yml

 - name: include distribution variables
  include_vars: "{{ item }}"
  with_first_found:
    - "{{ ansible_distribution }}/{{ ansible_distribution_major_version}}.yml"
    - "{{ ansible_distribution }}.yml"
  tags: [ 'always' ]
...
simonLeary42 commented 2 years ago

in roles/ood-ansible-2.0.6/tasks/main.yml:

- name: "Ansible | Print a variable"
  debug:
    msg: "ansible_distribution: {{ ansible_distribution }}"
- name: "Ansible | Print a variable"
  debug:
    msg: "path1: {{ ansible_distribution }}/{{ ansible_distribution_major_version}}.yml"
- name: "Ansible | Print a variable"
  debug:
    msg: "path2: {{ ansible_distribution }}.yml"

output:

TASK [ood-ansible-2.0.6 : Ansible | Print a variable] **************************************************************************************
ok: [ood] => {
    "msg": "path1: Ubuntu/22.yml"
}

TASK [ood-ansible-2.0.6 : Ansible | Print a variable] **************************************************************************************
ok: [ood] => {
    "msg": "path2: Ubuntu.yml"
}
simonLeary42 commented 2 years ago

~/ansible/roles/ood-ansible-2.0.6$ find . | grep Ubuntu ./vars/Ubuntu ./vars/Ubuntu/20.yml ./vars/Ubuntu/18.yml

so we only support ubuntu 18 and 20, but 20 doesn't work in my other ticket because we need the python3-dnf package Surely there's a more graceful way for ansible to fail when it can't find vars for a given distribution. Is there a supported operating system list somewhere that I should have been referencing?

simonLeary42 commented 2 years ago

Surely there's a more graceful way for ansible to fail when it can't find vars for a given distribution. https://github.com/OSC/ood-ansible/pull/152

simonLeary42 commented 2 years ago

Is there a supported operating system list somewhere that I should have been referencing? https://github.com/OSC/ood-ansible/pull/153