geerlingguy / ansible-for-kubernetes

Ansible and Kubernetes examples from Ansible for Kubernetes Book
https://www.ansibleforkubernetes.com
MIT License
667 stars 312 forks source link

Ansible is being run in a world writable directory... ignoring it as an ansible.cfg source #107

Open Xaeco opened 2 years ago

Xaeco commented 2 years ago

On page 74 in

Chapter 3 - Ansible manages containers

When running command:

$ ansible-galaxy install -r requirements.yml

It runs with a warning:

[WARNING]: Ansible is being run in a world writable directory (/mnt/c/Users/<username>/documents/afk/ansible-solr-container), ignoring it as
an ansible.cfg source. For more information see https://docs.ansible.com/ansible/devel/reference_appendices/config.html#cfg-in-world-     
writable-dir
Starting galaxy role install process
- downloading role 'java', owned by geerlingguy
- downloading role from https://github.com/geerlingguy/ansible-role-java/archive/1.10.0.tar.gz
- extracting geerlingguy.java to /home/wsl/.ansible/roles/geerlingguy.java
- geerlingguy.java (1.10.0) was installed successfully
- downloading role 'solr', owned by geerlingguy
- downloading role from https://github.com/geerlingguy/ansible-role-solr/archive/5.3.0.tar.gz
- extracting geerlingguy.solr to /home/wsl/.ansible/roles/geerlingguy.solr
- geerlingguy.solr (5.3.0) was installed successfully

It installs the roles but not in the correct location:

$ ls -1 roles
ls: cannot access 'roles': No such file or directory

Following the link in the warning leads to options to resolve the issue. I used:

export ANSIBLE_CONFIG=./ansible.cfg

then re-ran the command:

$ ansible-galaxy install -r requirements.yml

which put them into the correct location:

$ ls -1 roles
geerlingguy.java
geerlingguy.solr
geerlingguy commented 2 years ago

@Xaeco - Hmm... "Ansible is being run in a world writable directory" seems to indicate this directory has 777 permissions, and typically Ansible restricts loading ansible.cfg files in that case (for good reason—someone could do a lot of damage writing to that file!). I haven't ever noticed that warning, but did you by chance set the folder to have world-read/write/execute permissions?

Xaeco commented 2 years ago

My files are in my user profile documents folder in Windows and being accessed by Ansible within WSL. I have tried changing permissions in both environments and changing the mount to no avail.

So I went with the environment variable option for now as I'm planning on removing Windows this Xmas break and going full Linux to immerse myself for a while.

geerlingguy commented 2 years ago

going full Linux to immerse myself for a while.

Ooh, good luck!

Xaeco commented 2 years ago

Was tempted to quote a line from Tropic Thunder