Hello again!
I want to have a Playbook running in the background which checks for github releases.
I used to learn the recommended folder structure, but the playbook cant find the roles.
I Run the check_releases.yaml.
Structure:
ansible-project/
├── inventory
│ └── hosts
├── playbooks
│ └── check_releases.yaml
├── roles
│ ├── github_release_check
│ │ ├── tasks
│ │ │ ├── main.yaml
│ │ │ └── load_previous_releases.yaml
│ ├── rocketchat_notify
│ │ ├── tasks
│ │ │ └── main.yaml
├── group_vars
│ └── all.yaml
And this is my playbook:
---
- name: Check for new GitHub releases and notify via Rocket.Chat
hosts: localhost
gather_facts: false
roles:
- github_release_check
- rocketchat_notify
The Log:
ERROR! the role 'github_release_check' was not found in /runner/project/functions/check_gitgub_releases/playbooks/roles:/runner/requirements_roles:/runner/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/runner/project/functions/check_gitgub_releases/playbooks
The error appears to be in '/runner/project/functions/check_gitgub_releases/playbooks/check_releases.yaml': line 6, column 7, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
roles:
- github_release_check
^ here
The githubreleasecheck main:
---
- name: Check GitHub releases
vars:
releases_file: /tmp/github_releases.json
block:
- name: Fetch latest releases from GitHub
uri:
url: "https://api.github.com/repos/{{ item.owner }}/{{ item.name }}/releases/latest"
return_content: yes
headers:
Accept: "application/vnd.github.v3+json"
register: github_response
loop: "{{ github_repos }}"
changed_when: false
- name: Parse GitHub release data
set_fact:
new_releases: "{{ github_response.results | selectattr('status', 'eq', 200) | map(attribute='json') | list }}"
- name: Load previous releases data
include_tasks: load_previous_releases.yml
when: releases_file is file
- name: Save current releases data
copy:
content: "{{ new_releases | to_nice_json }}"
dest: "{{ releases_file }}"
changed_when: false
Thank you very much again!!