water-hole / ansible-operator

POC Code for the operator backed by ansible
48 stars 29 forks source link

Ensure tmp directory is created with proper permissions in base Dockerfile #63

Closed fabianvf closed 5 years ago

djzager commented 5 years ago

Here is my dockerfile:

FROM docker.io/djzager/ansible-operator:pr63

RUN ansible-galaxy install ansibleplaybookbundle.asb-modules

COPY . ${HOME}/roles/hello-world-apb
COPY playbooks ${HOME}/
COPY watches.yaml ${HOME}/watches.yaml

Run inside the hello-world-operator-container:

$ docker run -it --rm --entrypoint /bin/sh hello-world-operator
sh-4.2$ ls -lha /opt/ansible
total 52K
drwxrwx---. 1 ansible-operator root 4.0K Nov 19 19:01 .
drwxr-xr-x. 1 root             root 4.0K Nov 19 18:55 ..
drwx------. 3 ansible-operator root 4.0K Nov 19 19:01 .ansible
-rw-------. 1 ansible-operator root    0 Nov 19 19:01 .ansible_galaxy
-rw-r--r--. 1 ansible-operator root   18 Apr 11  2018 .bash_logout
-rw-r--r--. 1 ansible-operator root  193 Apr 11  2018 .bash_profile
-rw-r--r--. 1 ansible-operator root  231 Apr 11  2018 .bashrc
-rw-rw-r--. 1 root             root  212 May 31 17:02 deprovision.yml
-rw-rw-r--. 1 root             root  183 Nov 19 18:58 example.yml
-rw-rw-r--. 1 root             root  208 May 31 17:02 provision.yml
drwxr-xr-x. 1 ansible-operator root 4.0K Nov 19 19:01 roles
-rw-rw-r--. 1 root             root  452 Jun  8 18:08 test.yml
-rw-r--r--. 1 root             root  134 Nov 19 15:46 watches.yaml

Unfortunately, it's still angry:

time="2018-11-19T19:07:52Z" level=error msg="error from ansible-runner: exit status 1" component=runner job=4876351797210358247 name=example-helloworld namespace=hello-world
time="2018-11-19T19:07:52Z" level=error msg="did not receive playbook_on_stats event" component=reconciler job=4876351797210358247 name=example-helloworld namespace=hello-world
time="2018-11-19T19:07:52Z" level=error msg="Unhandled error:\r\n Traceback (most recent call last):\r\n  File \"/usr/lib/python2.7/site-packages/ansible/config/manager.py\", line 487, in update_config_data\r\n    value, origin = self.get_config_value_and_origin(config, configfile)\r\n  File \"/usr/lib/python2.7/site-packages/ansible/config/manager.py\", line 439, in get_config_value_and_origin\r\n    value = ensure_type(value, defs[config].get('type'), origin=origin)\r\n  File \"/usr/lib/python2.7/site-packages/ansible/config/manager.py\", line 91, in ensure_type\r\n    makedirs_safe(value, 0o700)\r\n  File \"/usr/lib/python2.7/site-packages/ansible/utils/path.py\", line 81, in makedirs_safe\r\n    raise AnsibleError(\"Unable to create local directories(%s): %s\" % (to_native(rpath), to_native(e)))\r\nAnsibleError: Unable to create local directories(/opt/ansible/.ansible/tmp): [Errno 13] Permission denied: '/opt/ansible/.ansible/tmp'\r\n\r\n\r\n\nTraceback (most recent call last):\r\n  File \"/usr/bin/ansible-playbook\", line 67, in <module>\r\n    import ansible.constants as C\r\n  File \"/usr/lib/python2.7/site-packages/ansible/constants.py\", line 184, in <module>\r\n    config = ConfigManager()\r\n  File \"/usr/lib/python2.7/site-packages/ansible/config/manager.py\", line 243, in __init__\r\n    self.update_config_data()\r\n  File \"/usr/lib/python2.7/site-packages/ansible/config/manager.py\", line 499, in update_config_data\r\n    raise AnsibleError(\"Invalid settings supplied for %s: %s\\n%s\" % (config, to_native(e), traceback.format_exc()))\r\nansible.errors.AnsibleError: Invalid settings supplied for DEFAULT_LOCAL_TMP: Unable to create local directories(/opt/ansible/.ansible/tmp): [Errno 13] Permission denied: '/opt/ansible/.ansible/tmp'\r\nTraceback (most recent call last):\r\n  File \"/usr/lib/python2.7/site-packages/ansible/config/manager.py\", line 487, in update_config_data\r\n    value, origin = self.get_config_value_and_origin(config, configfile)\r\n  File \"/usr/lib/python2.7/site-packages/ansible/config/manager.py\", line 439, in get_config_value_and_origin\r\n    value = ensure_type(value, defs[config].get('type'), origin=origin)\r\n  File \"/usr/lib/python2.7/site-packages/ansible/config/manager.py\", line 91, in ensure_type\r\n    makedirs_safe(value, 0o700)\r\n  File \"/usr/lib/python2.7/site-packages/ansible/utils/path.py\", line 81, in makedirs_safe\r\n    raise AnsibleError(\"Unable to create local directories(%s): %s\" % (to_native(rpath), to_native(e)))\r\nAnsibleError: Unable to create local directories(/opt/ansible/.ansible/tmp): [Errno 13] Permission denied: '/opt/ansible/.ansible/tmp'\r\n\r\n\n" component=reconciler job=4876351797210358247 name=example-helloworld namespace=hello-world
djzager commented 5 years ago
time="2018-11-19T20:28:09Z" level=info msg="Watching hello-world namespace."
time="2018-11-19T20:28:09Z" level=info msg="Go Version: go1.10"
time="2018-11-19T20:28:09Z" level=info msg="Go OS/Arch: linux/amd64"
time="2018-11-19T20:28:09Z" level=info msg="operator-sdk Version: v0.1.1+git"
time="2018-11-19T20:28:09Z" level=info msg="Starting to serve on 127.0.0.1:8888\n"
time="2018-11-19T20:28:09Z" level=info msg="Watching helloworld.example.com/v1alpha1, HelloWorld"
{"level":"info","ts":1542659289.8934646,"logger":"kubebuilder.controller","caller":"controller/controller.go:120","msg":"Starting EventSource","Controller":"helloworld-controller","Source":"kind source: helloworld.example.com/v1alpha1, Kind=HelloWorld"}
{"level":"info","ts":1542659289.9939463,"logger":"kubebuilder.controller","caller":"controller/controller.go:134","msg":"Starting Controller","Controller":"helloworld-controller"}
{"level":"info","ts":1542659290.0943484,"logger":"kubebuilder.controller","caller":"controller/controller.go:153","msg":"Starting workers","Controller":"helloworld-controller","WorkerCount":1}
time="2018-11-19T20:28:23Z" level=info msg="[playbook debug]: msg=Yay" component=logging_event_handler event_type=runner_on_ok gvk="helloworld.example.com/v1alpha1, Kind=HelloWorld" job=1614863421007246305 name=example-helloworld namespace=hello-world
time="2018-11-19T20:28:23Z" level=info msg="ansible-runner exited successfully" component=runner job=1614863421007246305 name=example-helloworld namespace=hello-world