Go to file
2023-11-23 08:18:38 +01:00
ansible explicitly enable http/2 2023-11-23 08:18:38 +01:00
ansible-runtime working state 2023-11-15 19:06:09 +01:00
README.md fix link in readme 2023-11-23 08:13:31 +01:00
task.md initial 2023-11-13 19:01:26 +01:00

the task

see task.md

deploy

python virtualenv

Because ansible setups have requirements towards used python versions, libraries etc, we use a separate python virtualenv.

export VENV_PATH='/tmp/venv'
# create the env
$ python -m venv "${VENV_PATH}"

# activate it
$ . "${VENV_PATH}/bin/activate"

# install pip dependencies
pip install -r ansible-runtime/requirements.txt

kick off the deployment

assumptions:

  • you have initialized and activated the venv as described above
  • the current user has ssh access to localhost
  • the current user can access the docker socket at /var/run/docker.sock
$ cd ansible
$ ansible-playbook -i inventory.yaml playbook.yaml

This deploys three containers and a network. List them:

# quick and dirty:
docker ps -a | grep userlike
# or with something like this:
docker ps --format json -a | yq -p json -ojson 'select(.Names|test("userlike-.*"))'

And confirm the routing works as expected:

curl -k https://localhost:8443/ # shall return one/two backend alternating responses
curl -k https://localhost:8443/one # shall only return "one" responses
curl -k https://localhost:8443/two # shall only return "two" responses

testing

some example queries to test for the given task

$ curl -k https://localhost:8443/
hello my friend, this is backend host "one" speaking.
have a nice day, mate.
$ curl -k https://localhost:8443/
hello my friend, this is backend host "two" speaking.
have a nice day, mate.
$ curl -k https://localhost:8443/one
hello my friend, this is backend host "one" speaking.
have a nice day, mate.
$ curl -k https://localhost:8443/one
hello my friend, this is backend host "one" speaking.
have a nice day, mate.
$ curl -k https://localhost:8443/two
hello my friend, this is backend host "two" speaking.
have a nice day, mate.
$ curl -k https://localhost:8443/two
hello my friend, this is backend host "two" speaking.
have a nice day, mate.
$ curl -k https://localhost:8443/two/index.html
hello my friend, this is backend host "two" speaking.
have a nice day, mate.
$ curl -k https://localhost:8443/two/index.html.nonexistent
<html>
<head><title>404 Not Found</title></head>
<body>
<center><h1>404 Not Found</h1></center>
<hr><center>nginx/1.23.4</center>
</body>
</html>
$ curl -k https://localhost:8443/index.html
<html><body><h1>503 Service Unavailable</h1>
No server is available to handle this request.
</body></html>
(venv) [fix@neon