geerlingguy / ansible-for-devops

Ansible for DevOps examples.
https://www.ansiblefordevops.com
MIT License
8.52k stars 3.48k forks source link

Ansible is being run in a world writable directory #421

Open MalcolmAnderson opened 3 years ago

MalcolmAnderson commented 3 years ago

My apologies, there's a lot to unpack below

I'm having an issue getting ansible and vagrant to play well with each other on WSL

If I run ansible from outside of the home directory (~) I get "Ansible is being run in a world writable directory"

But if I run vagrant in my home directory I get an error saying that it can't be there. (That was last weekend so I don't remember)

I've solved the "world writeable" issue by installing Ansible 2.6.0 pip install ansible==2.6.0

I tried setting wsl to have chod'able permissions by editing the /etc/wsl.conf file. Unfortunately that effectively locked me out of my system, wsl couldn't see any of the files.

Elsewhere I've mentioned that I had to downgrade the wsl version on my ubuntu distro to wsl 1. That seems to be working.

I believe I'm up and running, but this feels like an ugly hack.

If anyone has a guide for setting up ansible on wsl 2, I will be happy to live fire it for you.

My current progress is somewhere between chapter 3 or 4 (had to go back to 3 because of the "world writeable" issue.

I'll update this as I go forward.

MalcolmAnderson commented 3 years ago

Sigh, that worked for a while, but I seem to be hanging on commands that use to run. I'm assuming that its due to the old version of Ansible that I'm running.

MalcolmAnderson commented 3 years ago

OK, this is weird The first run didn't work, but the second one did. The runs were 3 minutes apart. I'll continue to update my progress.

00:48:38 mba@-20.04:/mnt/d/dev/DevOpsDev/a4DO/a4do_c03$ ansible multi -m copy -a "src=/etc/hosts dest=/tmp/hosts" 192.168.60.6 | FAILED! => { "changed": false, "checksum": "fe1aecbfecf4f5093fb99ade0bacab759819b8a4", "module_stderr": "Shared connection to 192.168.60.6 closed.\r\n", "module_stdout": "Traceback (most recent call last):\r\n File \"/tmp/ansible_kphnaz0v/ansible_module_copy.py\", line 805, in \r\n main()\r\n File \"/tmp/ansible_kphnaz0v/ansible_module_copy.py\", line 798, in main\r\n file_args = module.load_file_common_arguments(module.params, path=dest)\r\nTypeError: load_file_common_arguments() got an unexpected keyword argument 'path'\r\n", "msg": "MODULE FAILURE", "rc": 1 } 192.168.60.4 | FAILED! => { "changed": false, "checksum": "fe1aecbfecf4f5093fb99ade0bacab759819b8a4", "module_stderr": "Shared connection to 192.168.60.4 closed.\r\n", "module_stdout": "Traceback (most recent call last):\r\n File \"/tmp/ansible_8wxw43t1/ansible_module_copy.py\", line 805, in \r\n main()\r\n File \"/tmp/ansible_8wxw43t1/ansible_module_copy.py\", line 798, in main\r\n file_args = module.load_file_common_arguments(module.params, path=dest)\r\nTypeError: load_file_common_arguments() got an unexpected keyword argument 'path'\r\n", "msg": "MODULE FAILURE", "rc": 1 } 192.168.60.5 | FAILED! => { "changed": false, "checksum": "fe1aecbfecf4f5093fb99ade0bacab759819b8a4", "module_stderr": "Shared connection to 192.168.60.5 closed.\r\n", "module_stdout": "Traceback (most recent call last):\r\n File \"/tmp/ansible_v6u8f0kv/ansible_module_copy.py\", line 805, in \r\n main()\r\n File \"/tmp/ansible_v6u8f0kv/ansible_module_copy.py\", line 798, in main\r\n file_args = module.load_file_common_arguments(module.params, path=dest)\r\nTypeError: load_file_common_arguments() got an unexpected keyword argument 'path'\r\n", "msg": "MODULE FAILURE", "rc": 1 }

00:51:38 mba@-20.04:/mnt/d/dev/DevOpsDev/a4DO/a4do_c03$ ansible multi -m copy -a "src=/etc/hosts dest=/tmp/hosts" 192.168.60.6 | SUCCESS => { "changed": false, "checksum": "fe1aecbfecf4f5093fb99ade0bacab759819b8a4", "dest": "/tmp/hosts", "gid": 1000, "group": "vagrant", "mode": "0664", "owner": "vagrant", "path": "/tmp/hosts", "secontext": "unconfined_u:object_r:user_home_t:s0", "size": 638, "state": "file", "uid": 1000 } 192.168.60.5 | SUCCESS => { "changed": false, "checksum": "fe1aecbfecf4f5093fb99ade0bacab759819b8a4", "dest": "/tmp/hosts", "gid": 1000, "group": "vagrant", "mode": "0664", "owner": "vagrant", "path": "/tmp/hosts", "secontext": "unconfined_u:object_r:user_home_t:s0", "size": 638, "state": "file", "uid": 1000 } 192.168.60.4 | SUCCESS => { "changed": false, "checksum": "fe1aecbfecf4f5093fb99ade0bacab759819b8a4", "dest": "/tmp/hosts", "gid": 1000, "group": "vagrant", "mode": "0664", "owner": "vagrant", "path": "/tmp/hosts", "secontext": "unconfined_u:object_r:user_home_t:s0", "size": 638, "state": "file", "uid": 1000 }

MalcolmAnderson commented 3 years ago

00:59:15 mba@-20.04:/mnt/d/dev/DevOpsDev/a4DO/a4do_c03$ ansible multi -b -B 3600 -P 0 -a "yum -y update" 192.168.60.5 | FAILED | rc=-1 >> usage: async_wrapper [-preserve_tmp] Humans, do not call directly!

192.168.60.6 | FAILED | rc=-1 >> usage: async_wrapper [-preserve_tmp] Humans, do not call directly!

192.168.60.4 | FAILED | rc=-1 >> usage: async_wrapper [-preserve_tmp] Humans, do not call directly!

MalcolmAnderson commented 3 years ago

01:01:11 mba@-20.04:/mnt/d/dev/DevOpsDev/a4DO/a4do_c03$ ansible multi -b -m async_status -a "jid=169825235950.3572" An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'ActionModule' object has no attribute 'get_shell_option' 192.168.60.4 | FAILED! => { "msg": "Unexpected failure during module execution.", "stdout": "" } An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'ActionModule' object has no attribute 'get_shell_option' 192.168.60.5 | FAILED! => { "msg": "Unexpected failure during module execution.", "stdout": "" } An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'ActionModule' object has no attribute 'get_shell_option' 192.168.60.6 | FAILED! => { "msg": "Unexpected failure during module execution.", "stdout": "" }

MalcolmAnderson commented 3 years ago

I was able to run most of the commands between pages 35 and 42 using Ansible 2.6.0 But the book ends are installing git and then using it.

It's late so I'm going to bed.

MalcolmAnderson commented 3 years ago

I am giving up on using the book with Win10, and the machine that I have Linux on, apparently doesn't support virtualization, so now I'm using a Mac and it's running beautifully.

If anyone has a guide to setting up and running Ansible, Vagrant and Virtualbox on WSL (on a Win10 machine), I will be happy to try it out. I think there was a way, with aliasing the vagrant ssh directory to a specific folder but I couldn't figure it out.