product-demos icon indicating copy to clipboard operation
product-demos copied to clipboard

LINUX / Podman Webserver: Does not output message in survey; stops but is not deleted

Open benblasco opened this issue 2 years ago • 4 comments

This playbook outputs info that does not include the string put into the survey:

Identity added: /runner/artifacts/25/ssh_key_data (/runner/artifacts/25/ssh_key_data)
PLAY [Podman] ******************************************************************
TASK [Gathering Facts] *********************************************************
ok: [node3]
TASK [Install Podman] **********************************************************
changed: [node3]
TASK [Create volume dir] *******************************************************
changed: [node3]
TASK [Create index.html] *******************************************************
changed: [node3]
TASK [Run httpd container] *****************************************************
changed: [node3]
TASK [Check Web Page] **********************************************************
ok: [node3]
TASK [podman ps] ***************************************************************
ok: [node3]
TASK [Output] ******************************************************************
ok: [node3] => {
    "msg": [
        [
            "CONTAINER ID  IMAGE                           COMMAND           CREATED        STATUS            PORTS                 NAMES",
            "a0c89a3a3021  docker.io/library/httpd:latest  httpd-foreground  2 seconds ago  Up 2 seconds ago  0.0.0.0:8080->80/tcp  apache"
        ],
        "<html><body><h1>It works!</h1></body></html>\n"
    ]
}
PLAY RECAP *********************************************************************node3                      : ok=8    changed=4    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

The container then stops on the localhost but is never cleaned up:

[ec2-user@node3 ~]$ podman ps -a 
CONTAINER ID  IMAGE                           COMMAND           CREATED        STATUS                    PORTS                 NAMES
a0c89a3a3021  docker.io/library/httpd:latest  httpd-foreground  3 minutes ago  Exited (0) 3 minutes ago  0.0.0.0:8080->80/tcp  apache
[ec2-user@node3 ~]$ 

So the questions I have are:

  1. Where should i be able to see the string input into the survey? Via the playbook output or via curl localhost? I can't see it in either:
[ec2-user@node3 ~]$ podman start apache
apache
[ec2-user@node3 ~]$ curl localhost:8080
<html><body><h1>It works!</h1></body></html>
[ec2-user@node3 ~]$ 
  1. Should the container be deleted upon completion, or remain running?
  2. If you run this a second time, what's the expected behaviour? My observation is that it's idempotent so the container is left untouched, which is probably the desired outcome.

benblasco avatar Oct 25 '22 06:10 benblasco

I think this demo needs to be revisited as a whole. All valid questions but not much work has gone into what the intention of this is. Open to suggestions.

willtome avatar Oct 25 '22 20:10 willtome

I have found the issue with the string put into the survey not showing. It's this block of code in podman.yml

  - name: Run httpd container
    containers.podman.podman_container:
      name: apache
      image: docker.io/httpd
      state: started
      volume:
        - "{{ volume_path }}:/usr/local/apache2/htdocs"

The volume_path variable is being interpreted as a volume name, rather than a filesystem path. See troubleshooting below:

Firstly, the file containing the message from the survey is put here:

[ec2-user@node1 ~]$ cat podman/index.html 
BBLASCO This is a web page I want to look at! 

However podman creates a volume called podman, and this is the path mounted into the container:

[ec2-user@node1 ~]$ podman volume ls
DRIVER      VOLUME NAME
local       podman

[ec2-user@node1 ~]$ podman volume inspect podman
[
     {
          "Name": "podman",
          "Driver": "local",
          "Mountpoint": "/home/ec2-user/.local/share/containers/storage/volumes/podman/_data",
          "CreatedAt": "2022-11-21T01:32:52.823839021Z",
          "Labels": {},
          "Scope": "local",
          "Options": {},
          "MountCount": 0
     }
]
[ec2-user@node1 ~]$ cat /home/ec2-user/.local/share/containers/storage/volumes/podman/_data/index.html 
<html><body><h1>It works!</h1></body></html>
[ec2-user@node1 ~]$ 

So we have two options for fixing this: a) copy the correct message from the survey into the index.html in the podman volume named podman, OR b) Ensure that the volume_path directory is interpreted as a path, rather than a podman volume name

I am inclined to go with whatever is simpler and will lodge a PR to fix this.

benblasco avatar Nov 21 '22 03:11 benblasco

Took the path of least resistance here and chose option B, ensuring volume_path is interpreted as a path instead of a podman volume name. This demo could potentially do with more work, but at least it has some sensible output now.

benblasco avatar Nov 21 '22 04:11 benblasco

@MKletz @willtome Can we close this issue?

benblasco avatar Jan 17 '23 04:01 benblasco