Closed djzager closed 6 years ago
Example runthrough with multiple provisions in same namespace:
apb_id=2
(apb) ➜ hello-world-apb git:(apb-ref-example) ✗ docker run --rm --net=host -v $HOME/.kube:/opt/apb/.kube:z -u $UID hello-world-apb provision --extra-vars 'apb_id=2'
+ [[ provision --extra-vars apb_id=2 == *\s\2\i\/\a\s\s\e\m\b\l\e* ]]
+ ACTION=provision
+ shift
+ playbooks=/opt/apb/actions
+ CREDS=/var/tmp/bind-creds
+ TEST_RESULT=/var/tmp/test-result
+ whoami
+ '[' -w /etc/passwd ']'
++ id -u
+ echo 'apb:x:1000:0:apb user:/opt/apb:/sbin/nologin'
+ set +x
+ [[ -e /opt/apb/actions/provision.yaml ]]
+ [[ -e /opt/apb/actions/provision.yml ]]
+ ANSIBLE_ROLES_PATH=/etc/ansible/roles:/opt/ansible/roles
+ ansible-playbook /opt/apb/actions/provision.yml --extra-vars apb_id=2
PLAY [hello-world-apb provision] ***********************************************
TASK [hello-world-apb : deployment config] *************************************
changed: [localhost]
TASK [hello-world-apb : hello-world service] ***********************************
changed: [localhost]
TASK [hello-world-apb : create hello-world route] ******************************
changed: [localhost]
PLAY RECAP *********************************************************************
localhost : ok=3 changed=3 unreachable=0 failed=0
+ EXIT_CODE=0
+ set +ex
+ '[' -f /var/tmp/test-result ']'
+ exit 0
apb_id=1
$ hello-world-apb git:(apb-ref-example) ✗ docker run --rm --net=host -v $HOME/.kube:/opt/apb/.kube:z -u $UID hello-world-apb provision --extra-vars 'apb_id=1'
+ [[ provision --extra-vars apb_id=1 == *\s\2\i\/\a\s\s\e\m\b\l\e* ]]
+ ACTION=provision
+ shift
+ playbooks=/opt/apb/actions
+ CREDS=/var/tmp/bind-creds
+ TEST_RESULT=/var/tmp/test-result
+ whoami
+ '[' -w /etc/passwd ']'
++ id -u
+ echo 'apb:x:1000:0:apb user:/opt/apb:/sbin/nologin'
+ set +x
+ [[ -e /opt/apb/actions/provision.yaml ]]
+ [[ -e /opt/apb/actions/provision.yml ]]
+ ANSIBLE_ROLES_PATH=/etc/ansible/roles:/opt/ansible/roles
+ ansible-playbook /opt/apb/actions/provision.yml --extra-vars apb_id=1
PLAY [hello-world-apb provision] ***********************************************
TASK [hello-world-apb : deployment config] *************************************
changed: [localhost]
TASK [hello-world-apb : hello-world service] ***********************************
changed: [localhost]
TASK [hello-world-apb : create hello-world route] ******************************
changed: [localhost]
PLAY RECAP *********************************************************************
localhost : ok=3 changed=3 unreachable=0 failed=0
+ EXIT_CODE=0
+ set +ex
+ '[' -f /var/tmp/test-result ']'
+ exit 0
$ oc get all -n hello-world
NAME REVISION DESIRED CURRENT TRIGGERED BY
deploymentconfigs/hello-world-5acebd43-ef18-5da4-9d08-543ae781fcab 1 1 0 config
deploymentconfigs/hello-world-dae097b5-4296-5d3f-8cc4-4acee86b3676 1 1 0 config
NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD
routes/hello-world-5acebd43-ef18-5da4-9d08-543ae781fcab hello-world-5acebd43-ef18-5da4-9d08-543ae781fcab-hello-world.172.17.0.1.nip.io hello-world-5acebd43-ef18-5da4-9d08-543ae781fcab web None
routes/hello-world-dae097b5-4296-5d3f-8cc4-4acee86b3676 hello-world-dae097b5-4296-5d3f-8cc4-4acee86b3676-hello-world.172.17.0.1.nip.io hello-world-dae097b5-4296-5d3f-8cc4-4acee86b3676 web None
NAME READY STATUS RESTARTS AGE
po/hello-world-5acebd43-ef18-5da4-9d08-543ae781fcab-1-deploy 0/1 Error 0 14s
po/hello-world-dae097b5-4296-5d3f-8cc4-4acee86b3676-1-deploy 0/1 Error 0 8s
NAME DESIRED CURRENT READY AGE
rc/hello-world-5acebd43-ef18-5da4-9d08-543ae781fcab-1 0 0 0 14s
rc/hello-world-dae097b5-4296-5d3f-8cc4-4acee86b3676-1 0 0 0 8s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
svc/hello-world-5acebd43-ef18-5da4-9d08-543ae781fcab ClusterIP 172.30.237.56 <none> 8080/TCP 13s
svc/hello-world-dae097b5-4296-5d3f-8cc4-4acee86b3676 ClusterIP 172.30.221.152 <none> 8080/TCP 7s
apb_id=2
$ docker run --rm --net=host -v $HOME/.kube:/opt/apb/.kube:z -u $UID hello-world-apb deprovision --extra-vars 'apb_id=2'
+ [[ deprovision --extra-vars apb_id=2 == *\s\2\i\/\a\s\s\e\m\b\l\e* ]]
+ ACTION=deprovision
+ shift
+ playbooks=/opt/apb/actions
+ CREDS=/var/tmp/bind-creds
+ TEST_RESULT=/var/tmp/test-result
+ whoami
+ '[' -w /etc/passwd ']'
++ id -u
+ echo 'apb:x:1000:0:apb user:/opt/apb:/sbin/nologin'
+ set +x
+ [[ -e /opt/apb/actions/deprovision.yaml ]]
+ [[ -e /opt/apb/actions/deprovision.yml ]]
+ ANSIBLE_ROLES_PATH=/etc/ansible/roles:/opt/ansible/roles
+ ansible-playbook /opt/apb/actions/deprovision.yml --extra-vars apb_id=2
PLAY [hello-world-apb deprovision] *********************************************
TASK [hello-world-apb : deployment config] *************************************
changed: [localhost]
TASK [hello-world-apb : hello-world service] ***********************************
changed: [localhost]
TASK [hello-world-apb : create hello-world route] ******************************
changed: [localhost]
PLAY RECAP *********************************************************************
localhost : ok=3 changed=3 unreachable=0 failed=0
+ EXIT_CODE=0
+ set +ex
+ '[' -f /var/tmp/test-result ']'
+ exit 0
apb_id=1
survived$ oc get all -n hello-world
NAME REVISION DESIRED CURRENT TRIGGERED BY
deploymentconfigs/hello-world-dae097b5-4296-5d3f-8cc4-4acee86b3676 1 1 0 config
NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD
routes/hello-world-dae097b5-4296-5d3f-8cc4-4acee86b3676 hello-world-dae097b5-4296-5d3f-8cc4-4acee86b3676-hello-world.172.17.0.1.nip.io hello-world-dae097b5-4296-5d3f-8cc4-4acee86b3676 web None
NAME READY STATUS RESTARTS AGE
po/hello-world-dae097b5-4296-5d3f-8cc4-4acee86b3676-1-deploy 0/1 Error 0 6m
NAME DESIRED CURRENT READY AGE
rc/hello-world-dae097b5-4296-5d3f-8cc4-4acee86b3676-1 0 0 0 6m
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
svc/hello-world-dae097b5-4296-5d3f-8cc4-4acee86b3676 ClusterIP 172.30.221.152 <none> 8080/TCP 6m
@djzager I'm liking the simplified structure!
Here's an idea of what it could look like to add per-container config-roles (aka container-enabled) to the APB: https://github.com/djzager/Hello-World-APB/pull/1
Maybe the container name shouldn't be the same as the pod's name, in case there's multiple containers deployed to the pod and we want to easily differentiate them?
Any ideas why deprovision is failing?
@djzager what are next steps with this PR?
@jwmatthews The next steps are:
I'm using this PR to test the changes in --> https://github.com/ansibleplaybookbundle/apb-test-shim/pull/4 In the end this will rely on that PR being merged.
@fabianvf + @dymurray I think this is ready to go
Updated the example to use lookups based on @fabianvf request. Now this is blocked by https://github.com/ansible/ansible/pull/37533 ... once that is merged I'll make sure everything is good to go and get :+1: again.
Putting this here for when I forget. The kubernetes latest is going to fail because of https://github.com/kubernetes/minikube/issues/2629
I'm playing around/investigating with a "modernized" APB example. The end goal is to have something showing off
openshift_raw
andk8s_raw
as well as a functioning test playbook. Right now though I've restructured this APB into a single role and wanted to get feedback before moving any further.