ansibleplaybookbundle / ansible-playbook-bundle

THIS REPO IS MIGRATING: https://github.com/automationbroker/apb
GNU General Public License v2.0
140 stars 70 forks source link

“apb list”: Exception occurred! [Errno 2] No such file or directory: '/root/.kube/config' #298

Open silencehe09 opened 6 years ago

silencehe09 commented 6 years ago

Dear author: I need your help. I have commented the condition "apb should not be run as root" in apb-docker-run.sh , because I have to run docker with root user (without considering about security in my experimental env). And I have run "apb init apb-demo && cd apb-demo && apb build " successfully. But I got exception when executing "apb list", "apb bootstrap" and so on. I have already logged in openshift with cluster-admin role . The following are some shell cmds and output:

[root@localhost data]# apb init apb-demo
Running APB image: ansibleplaybookbundle/apb-tools:latest
groupadd: GID '0' already exists
usermod: group 'apb' does not exist
Initializing /mnt/apb-demo for an APB.
Generating playbook files
Successfully initialized project directory at: /mnt/apb-demo
Please run *apb prepare* inside of this directory after editing files.
[root@localhost data]# cd apb-demo
[root@localhost apb-demo]# apb build
Running APB image: ansibleplaybookbundle/apb-tools:latest
groupadd: GID '0' already exists
usermod: group 'apb' does not exist
Finished writing dockerfile.
Building APB using tag: [apb-demo]
Successfully built APB image: apb-demo
[root@localhost apb-demo]# docker images | grep apb-demo
apb-demo                                             latest              7c7fb3baf209        14 seconds ago      603.8 MB
[root@localhost apb-demo]# apb list
Running APB image: ansibleplaybookbundle/apb-tools:latest
groupadd: GID '0' already exists
usermod: group 'apb' does not exist
Exception occurred! [Errno 2] No such file or directory: '/root/.kube/config'
[root@localhost apb-demo]# oc whoami
XXXXX(my user name)
[root@localhost apb-demo]# cat /root/.kube/config
apiVersion: v1
clusters:
- cluster:
    insecure-skip-tls-verify: true
    server: xxx
  name: xxxx
...

The Linux version is CentOS7 (Linux localhost.localdomain 3.10.0-514.el7.x86_64).

rgolangh commented 6 years ago

Edit the script again, and in the place where it says -u $UID put -u 1000 . If that works well I'll send a patch to fix it, like in this one here https://github.com/ansibleplaybookbundle/ansible-playbook-bundle/blob/52cff6fb5d7445ad0820a988491ab804672f42c9/scripts/apb-docker-run.sh#L46

ppanero commented 6 years ago

I run into the same problem, and I can confirm this fixed the issue.

Cheers

rgolangh commented 6 years ago

The more elegant solution is just add the KUBECONFIG variable to match the volume path

-e KUBECONFIG=/.kube/config

And that will work with any $UID and will prevent errors like if the $HOME/.kube dir ownership is by uid which is not 1000.