Local file access?

Hello!
Is there a way to acces the local project dir in the cubernetes enviroment?
Ive read that you shold just for testing, but i dont know why its not recommended tis way like in Docker its more common to mount a Container path to a local one or access the control via terminal, but why not with Docker Compose?

I propably would use the access teporarly, because i have a host with an old OS (stoneage OpenSuse 11.1 nagios core 3 server noone cared to update until its now way too complicated) and i need the SSH only for this host to be communitaed via ssh-rsa.

It is unclear at least to me what you are trying to do. Perhaps post a copy of your playbook, the expected -vs- actual behavior, and the results running the playbook with -vvv?

In answer to your generic question - Is there a way to access the local project dir - do you mean what delegate_to: localhost does? From Controlling where tasks run: delegation and local actions — Ansible Documentation

I really would like to know how to do the same for docker , but for the AWX enviroment.

docker container exec -it Containername /bin/bash

It would improove the speed i have to set someting up and i can see what happens in the background after each change to understand the system and for better debug.
then i could edit the local settings directly for one special case -if possible.
But if omething is a systembreaker i can restore via snapshot etc.

This is really more of a Kubernetes question than an AWX question, but that said, you should be able to do something like:

kubectl get pod -n awx  # or replace awx with whatever namespace you used

and then:

kubectl exec -it -n awx <your pod name> -c awx-web -- /bin/bash

or use -c awx-task if you want to shell into a task pod instead.

I’m not entirely sure what you are trying to do, so I’m not entirely sure which deployment and container you need to use.

Generally you want to change things via the deployment options instead. Typically the only time to shell into the container directly is when debugging something.

1 Like

it seems to be quite the same command as for docker, but somehow i cant connect:

The container name (the argument you give to -c) will be the same as your deployment name, plus “-web” or “-task” depending on the pod you’re connecting to.

So your second-to-last command should work (you need to use the full pod name), and it looks like your deployment name is awx-demo, so you just need to change the -c param to -c awx-demo-web.

So your full command would be:

kubectl exec -it -n awx awx-demo-web-69f8b797dd-t71vb -c awx-demo-web -- /bin/bash

I believe that should work.

You can see information about (and names of) the running containers in the pod with kubectl describe pod -n awx <full pod name>


It still doesnt like me.
Womewhat weiird because you can clearly see´the pod names

oot@ansiblesrv:~# kubectl get svc -n awx
NAME                                              TYPE        CLUSTER-IP    EXTERNAL-IP   PORT(S)        AGE
awx-operator-controller-manager-metrics-service   ClusterIP   10.43.48.47   <none>        8443/TCP       11d
awx-demo-postgres-13                              ClusterIP   None          <none>        5432/TCP       10d
awx-demo-service                                  NodePort    10.43.27.2    <none>        80:32000/TCP   10d
root@ansiblesrv:~# kubectl exec -it -n awx awx-demo-service -c awx-web -- /bin/bash
Error from server (NotFound): pods "awx-demo-service" not found
root@ansiblesrv:~# kubectl exec -it -n awx awx-demo-web-69f8b797dd-t7lvb -c awx-web -- /bin/bash
Error from server (BadRequest): container awx-web is not valid for pod awx-demo-web-69f8b797dd-t7lvb
root@ansiblesrv:~# kubectl exec -it -n awx 69f8b797dd-t7lvb -c awx-web -- /bin/bash
Error from server (NotFound): pods "69f8b797dd-t7lvb" not found
root@ansiblesrv:~# ^C
root@ansiblesrv:~# kubectl exec -it awx-demo-web-69f8b797dd-t7lvb -- /bin/bash
Error from server (NotFound): pods "awx-demo-web-69f8b797dd-t7lvb" not found
root@ansiblesrv:~# kubectl exec -it awx-demo-web-69f8b797dd-t7lvb -- /bin/sh
Error from server (NotFound): pods "awx-demo-web-69f8b797dd-t7lvb" not found
root@ansiblesrv:~# Welcome to Ubuntu 22.04.3 LTS (GNU/Linux 5.15.0-92-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/pro

This system has been minimized by removing packages and content that are
not required on a system that users do not log into.

To restore this content, you can run the 'unminimize' command.
Last login: Mon Feb 12 09:04:24 2024 from 10.10.100.14
root@ansiblesrv:~# kubectl exec -it -n awx awx-demo-web-69f8b797dd-t71vb -c awx-demo-web -- /bin/bash
Error from server (NotFound): pods "awx-demo-web-69f8b797dd-t71vb" not found
root@ansiblesrv:~# describe pod -n awx awx-demo-web-69f8b797dd-t7lvb
-bash: describe: command not found
root@ansiblesrv:~# describe pod
-bash: describe: command not found
root@ansiblesrv:~# kubectl describe pod -n awx awx-demo-web-69f8b797dd-t7lvb
Name:             awx-demo-web-69f8b797dd-t7lvb
Namespace:        awx
Priority:         0
Service Account:  awx-demo
Node:             ansiblesrv/192.168.151.130
Start Time:       Thu, 01 Feb 2024 09:49:40 +0000
Labels:           app.kubernetes.io/component=awx
                  app.kubernetes.io/managed-by=awx-operator
                  app.kubernetes.io/name=awx-demo-web
                  app.kubernetes.io/operator-version=2.10.0
                  app.kubernetes.io/part-of=awx-demo
                  app.kubernetes.io/version=23.6.0
                  pod-template-hash=69f8b797dd
Annotations:      checksum-configmaps-config: 58a036152c6073629e8a5941a99ffbe2ec424d7a
                  checksum-secret-bundle_cacert: da39a3ee5e6b4b0d3255bfef95601890afd80709
                  checksum-secret-ldap_cacert: da39a3ee5e6b4b0d3255bfef95601890afd80709
                  checksum-secret-receptor_ca: 8bfb865a5edb6bff59be1b0479b1134621e2a627
                  checksum-secret-receptor_work_signing: cec3511763a434bb7d72b34483d08695df97be99
                  checksum-secret-route_tls: da39a3ee5e6b4b0d3255bfef95601890afd80709
                  checksum-secret-secret_key: 2cea61b21f5406efee767734f012e255b007b365
                  checksum-secrets-app_credentials: 64537143229275d37d41e3ebb1f875108b4a2fe0
                  checksum-storage-persistent: adc83b19e793491b1c6ea0fd8b46cd9f32e592fc
                  kubectl.kubernetes.io/default-container: awx-demo-web
Status:           Running
IP:               10.42.0.18
IPs:
  IP:           10.42.0.18
Controlled By:  ReplicaSet/awx-demo-web-69f8b797dd
Containers:
  redis:
    Container ID:  containerd://11e3b2eabe3bcc9615bb879484d6aee8dbbc24a02646b69d76016054b6e1e243
    Image:         docker.io/redis:7
    Image ID:      docker.io/library/redis@sha256:b5ddcd52d425a8e354696c022f392fe45fca928f68d6289e6bb4a709c3a74668
    Port:          <none>
    Host Port:     <none>
    Args:
      redis-server
      /etc/redis.conf
    State:          Running
      Started:      Thu, 01 Feb 2024 09:50:21 +0000
    Ready:          True
    Restart Count:  0
    Requests:
      cpu:        50m
      memory:     64Mi
    Environment:  <none>
    Mounts:
      /data from awx-demo-redis-data (rw)
      /etc/redis.conf from awx-demo-redis-config (ro,path="redis.conf")
      /var/run/redis from awx-demo-redis-socket (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-gczm8 (ro)
  awx-demo-web:
    Container ID:  containerd://5d1133b6bb2a7f31d11ba681aab93ef9a4907065525aa61c39f283a328b8174e
    Image:         quay.io/ansible/awx:23.6.0
    Image ID:      quay.io/ansible/awx@sha256:d35a66b71f12e117f4de6e1f614eefa9c890edbfd5ed397987796eeb9a1c358d
    Port:          8052/TCP
    Host Port:     0/TCP
    Args:
      /usr/bin/launch_awx_web.sh
    State:          Running
      Started:      Thu, 01 Feb 2024 09:51:42 +0000
    Ready:          True
    Restart Count:  0
    Requests:
      cpu:     100m
      memory:  128Mi
    Environment:
      AWX_COMPONENT:           web
      SUPERVISOR_CONFIG_PATH:  /etc/supervisord_web.conf
      MY_POD_NAMESPACE:        awx (v1:metadata.namespace)
      MY_POD_IP:                (v1:status.podIP)
      UWSGI_MOUNT_PATH:        /
    Mounts:
      /etc/nginx/nginx.conf from awx-demo-nginx-conf (ro,path="nginx.conf")
      /etc/receptor/tls/ca/mesh-CA.crt from awx-demo-receptor-ca (ro,path="tls.crt")
      /etc/receptor/tls/ca/mesh-CA.key from awx-demo-receptor-ca (ro,path="tls.key")
      /etc/receptor/work_public_key.pem from awx-demo-receptor-work-signing (ro,path="work-public-key.pem")
      /etc/tower/SECRET_KEY from awx-demo-secret-key (ro,path="SECRET_KEY")
      /etc/tower/conf.d/credentials.py from awx-demo-application-credentials (ro,path="credentials.py")
      /etc/tower/conf.d/execution_environments.py from awx-demo-application-credentials (ro,path="execution_environments.py")
      /etc/tower/conf.d/ldap.py from awx-demo-application-credentials (ro,path="ldap.py")
      /etc/tower/settings.py from awx-demo-settings (ro,path="settings.py")
      /etc/tower/uwsgi.ini from awx-demo-uwsgi-config (ro,path="uwsgi.conf")
      /var/run/awx-rsyslog from rsyslog-socket (rw)
      /var/run/redis from awx-demo-redis-socket (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-gczm8 (ro)
  awx-demo-rsyslog:
    Container ID:  containerd://71a8b46d402f7ba33291dc239bc5bac13da6bd1b5f0504ad873f17d0347fbade
    Image:         quay.io/ansible/awx:23.6.0
    Image ID:      quay.io/ansible/awx@sha256:d35a66b71f12e117f4de6e1f614eefa9c890edbfd5ed397987796eeb9a1c358d
    Port:          <none>
    Host Port:     <none>
    Args:
      /usr/bin/launch_awx_rsyslog.sh
    State:          Running
      Started:      Thu, 01 Feb 2024 09:51:42 +0000
    Ready:          True
    Restart Count:  0
    Requests:
      cpu:     100m
      memory:  128Mi
    Environment:
      SUPERVISOR_CONFIG_PATH:  /etc/supervisord_rsyslog.conf
    Mounts:
      /etc/tower/SECRET_KEY from awx-demo-secret-key (ro,path="SECRET_KEY")
      /etc/tower/conf.d/credentials.py from awx-demo-application-credentials (ro,path="credentials.py")
      /etc/tower/settings.py from awx-demo-settings (ro,path="settings.py")
      /var/run/awx-rsyslog from rsyslog-socket (rw)
      /var/run/redis from awx-demo-redis-socket (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-gczm8 (ro)
Conditions:
  Type              Status
  Initialized       True
  Ready             True
  ContainersReady   True
  PodScheduled      True
Volumes:
  awx-demo-receptor-ca:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  awx-demo-receptor-ca
    Optional:    false
  awx-demo-receptor-work-signing:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  awx-demo-receptor-work-signing
    Optional:    false
  awx-demo-application-credentials:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  awx-demo-app-credentials
    Optional:    false
  awx-demo-secret-key:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  awx-demo-secret-key
    Optional:    false
  awx-demo-settings:
    Type:      ConfigMap (a volume populated by a ConfigMap)
    Name:      awx-demo-awx-configmap
    Optional:  false
  awx-demo-nginx-conf:
    Type:      ConfigMap (a volume populated by a ConfigMap)
    Name:      awx-demo-awx-configmap
    Optional:  false
  awx-demo-redis-config:
    Type:      ConfigMap (a volume populated by a ConfigMap)
    Name:      awx-demo-awx-configmap
    Optional:  false
  awx-demo-uwsgi-config:
    Type:      ConfigMap (a volume populated by a ConfigMap)
    Name:      awx-demo-awx-configmap
    Optional:  false
  awx-demo-redis-socket:
    Type:       EmptyDir (a temporary directory that shares a pod's lifetime)
    Medium:
    SizeLimit:  <unset>
  awx-demo-redis-data:
    Type:       EmptyDir (a temporary directory that shares a pod's lifetime)
    Medium:
    SizeLimit:  <unset>
  rsyslog-socket:
    Type:       EmptyDir (a temporary directory that shares a pod's lifetime)
    Medium:
    SizeLimit:  <unset>
  receptor-socket:
    Type:       EmptyDir (a temporary directory that shares a pod's lifetime)
    Medium:
    SizeLimit:  <unset>
  awx-demo-receptor-config:
    Type:      ConfigMap (a volume populated by a ConfigMap)
    Name:      awx-demo-awx-configmap
    Optional:  false
  kube-api-access-gczm8:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    ConfigMapOptional:       <nil>
    DownwardAPI:             true
QoS Class:                   Burstable
Node-Selectors:              <none>
Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                             node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:                      <none>

I missed an “l” :frowning: I was typing it out by hand from your original screenshot.

awx-demo-web-69f8b797dd-t7vb should be awx-demo-web-69f8b797dd-t7lvb

thats it!
Thank you!!!