Ansible: using role dependencies

37 views Asked by At

Trying to create a role for installing and configuring dokuwiki. Dokuwiki uses php. I've made the choice to impose Apache for this particular role.

My understanding is that the proper way to install those packages would be to use roles that would deal with the various aspects of installing and configuring those tools.

Therefore, I'm using geerlingguy.apache and geerlingguy.php. The tasks and variables in my role are organized accordingly.

My role tree:

ansible-role-dokuwiki
├── defaults
│   └── main.yml
├── handlers
│   └── main.yml
├── meta
│   └── main.yml
├── roles
│   ├── geerlingguy.apache
│   └── geerlingguy.php
├── tasks
│   ├── download_dokuwiki.yml
│   ├── main.yml
│   └── selinux_config.yml
├── vars
│   ├── Debian.yml
│   └── RedHat.yml
├── LICENSE
└── README.m

ansible-role-dokuwiki/tasks/main.yml:

---
- name: Selects PHP:7.4 (RedHat)
  command: "dnf module enable -y php:7.4"
  when: ansible_os_family == "RedHat"

- name: Install php
  include_role:
    name: geerlingguy.php

- name: Install apache
  include_role:
    name: geerlingguy.apache

# The rest of the tasks goes here

I've created this playbook, that uses my role, to install dokuwiki:

server_setup.yaml:

---
- hosts: all
  roles:
    - roles/dokuwiki

And I get this error:

ERROR! the role 'geerlingguy.apache' was not found in [several local paths]

The error appears to be in '/path/to/ansible-role-dokuwiki/meta/main.yml': line 3, column 5, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

dependencies:
  - role: geerlingguy.apache
    ^ here

Seems like I'm missing something essential in the way to deal with dependencies and/or the way to make several roles interact together...

Any help would be greatly appreciated.

Cheers

0

There are 0 answers