0

I'm running ansible(2.8.4) on a playbook built largely by operator-sdk on WSL(Ubuntu 18.04). I am receiving the following error.

ERROR! the role 'DistZilla' was not found in /home/####/projects/dist-zilla-operator/roles/roles:/home/####/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/home/####/projects/dist-zilla-operator/roles

This is the contents of the roles/playbook.yml file and a tree of the roles dir:

---
- hosts: localhost
  roles:
    - DistZilla

$ tree roles
roles
├── distzilla
│   ├── defaults
│   │   └── main.yml
│   ├── handlers
│   │   └── main.yml
│   ├── meta
│   │   └── main.yml
│   ├── README.md
│   ├── tasks
│   │   ├── base.yml
│   │   ├── _grant_image_puller.yml
│   │   ├── main.yml
│   │   └── _stage.yml
│   ├── templates
│   │   ├── buildConfig.yml.j2
│   │   ├── imageStream.yml.j2
│   │   ├── roleBinding.yml.j2
│   │   └── role.yml.j2
│   └── vars
│       └── main.yml
├── playbook.retry
└── playbook.yml

An strace shows that it is looking for roles/DistZilla, but refuses to look for roles/distzilla, though this doesn't appear to be a problem for other users of ansible. It seems to get past this error if I force the role to be lowercase in the playbook.yml, but, in theory, it should be able to accept the Pascal Case just fine.

I've tried with python 2.7.15 and 3.7.3. I've tried with and without the basic config file. Tried with and without a host file. Tried with and without '-c local'. I've even added a bunch of debugging prints to ansible/playbook/role/definition.py _load_role_path, but haven't seen any obvious cause.

Any insight with regards to how ansible-playbook interprets roles and looks for the path is greatly welcome.

1
  • This works for folks I work with who have ansible installed on a mac using brew. It only seems to be me, on WSL, who can't find the file if the Role is pascal case in the playbook.
    – David F
    Commented Sep 9, 2019 at 20:03

1 Answer 1

0

This interaction depends on the underlying filesystem. If it's case insensitive (HFS+ on MacOSX) you can ignore casing in the roles directive. Most Linux filesystems are case sensitive by default so you need to write the correct casing.

On WSL it's less clear. It could be case insensitive or not depending on your settings and where the file is located. I think anyting in /mnt/c/ is case insensitive by default:

cd /mnt/c/test && echo lower > test && echo UPPER > TEST && ls -lah
-rwxrwxrwx 1 XXX XXX    6 Sep 11 11:27  test

Compared to:

cd ~ && echo lower > test && echo UPPER > TEST && ls -lah
-rw-rw-rw- 1 XXX XXX    6 Sep 11 11:29 test
-rw-rw-rw- 1 XXX XXX    6 Sep 11 11:29 TEST

In general I would recommend full lower case names for roles (with underscores for clarity). This is what happens when you download a role through Ansible Galaxy ( https://galaxy.ansible.com/docs/contributing/creating_role.html ):

role_name

Optional. Use to override the name of the role.

In the past, Galaxy would apply a regex expression to the GitHub repository name and automatically remove ‘ansible-‘ and ‘ansible-role-‘. For example, if your repository name was ‘ansible-role-apache’, the role name would translate to ‘apache’. Galaxy no longer does this automatically. Instead, use the role_name setting to tell Galaxy what the role name should be.

If no value is provided, then the role name will match the repository name, with a couple of exceptions, including: converting the name to all lowercase, and replacing any ‘-‘ or ‘.’ characters with ‘_’.
1
  • Thank you for this insight! I didn't know mac's file system was case insensitive, but this would, I think, explain things. My project is very much in the Ubuntu fs and not in /mnt.
    – David F
    Commented Sep 12, 2019 at 16:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .