Skip to content

Instantly share code, notes, and snippets.

@Tzrlk
Created July 11, 2018 02:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tzrlk/b5ecafe3eb5adeabeed4796b5b33f1a9 to your computer and use it in GitHub Desktop.
Save Tzrlk/b5ecafe3eb5adeabeed4796b5b33f1a9 to your computer and use it in GitHub Desktop.
Files related to ansible k8s module "Incorrect Padding" issue
docker run --rm -v /c/code/devops/ansible://work -e http_proxy=http://proxy:3128/ -e https_proxy=http://proxy:3128/ -e no_proxy=127.0.0.1,localhost,local tzrlk/ansible ansible-playbook -vvv \
playbooks/k8s_virginia.yml
ansible-playbook 2.5.5
config file = /work/ansible.cfg
configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /usr/bin/ansible-playbook
python version = 2.7.14 (default, Feb 22 2018, 21:59:35) [GCC 6.3.0]
Using /work/ansible.cfg as config file
Parsed /work/inventories/localhost.yml inventory source with yaml plugin
PLAYBOOK: k8s_virginia.yml *****************************************
1 plays in playbooks/k8s_virginia.yml
PLAY [Set up kubernetes resources] *****************
META: ran handlers
TASK [k8s_cluster : Set up Kubernetes authentication] **********************
task path: /work/roles/k8s_cluster/tasks/main.yml:3
included: /work/roles/k8s_cluster/tasks/auth.yml for localhost
TASK [k8s_cluster : Ensure aws config directory exists] ********************
task path: /work/roles/k8s_cluster/tasks/auth.yml:3
Using module file /usr/lib/python2.7/site-packages/ansible/modules/files/file.py
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<localhost> EXEC /bin/sh -c 'echo ~root && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp/ansible-tmp-1531261686.22-40206080020902 `" && echo ansible-tmp-1531261686.22-40206080020902="` echo /root/.ansible/tmp/ansible-tmp-1531261686.22-40206080020902 `" ) && sleep 0'
<localhost> PUT /root/.ansible/tmp/ansible-local-1azbLzk/tmpfTA4pc TO /root/.ansible/tmp/ansible-tmp-1531261686.22-40206080020902/file.py
<localhost> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1531261686.22-40206080020902/ /root/.ansible/tmp/ansible-tmp-1531261686.22-40206080020902/file.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python /root/.ansible/tmp/ansible-tmp-1531261686.22-40206080020902/file.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1531261686.22-40206080020902/ > /dev/null 2>&1 && sleep 0'
changed: [localhost] => {
"changed": true,
"diff": {
"after": {
"path": "/root/.aws",
"state": "directory"
},
"before": {
"path": "/root/.aws",
"state": "absent"
}
},
"gid": 0,
"group": "root",
"invocation": {
"module_args": {
"attributes": null,
"backup": null,
"content": null,
"delimiter": null,
"diff_peek": null,
"directory_mode": null,
"follow": true,
"force": false,
"group": null,
"mode": null,
"original_basename": null,
"owner": null,
"path": "/root/.aws",
"recurse": false,
"regexp": null,
"remote_src": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"src": null,
"state": "directory",
"unsafe_writes": null,
"validate": null
}
},
"mode": "0755",
"owner": "root",
"path": "/root/.aws",
"size": 4096,
"state": "directory",
"uid": 0
}
TASK [k8s_cluster : Generate aws profile configuration] ********************
task path: /work/roles/k8s_cluster/tasks/auth.yml:8
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<localhost> EXEC /bin/sh -c 'echo ~root && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp/ansible-tmp-1531261686.41-17595121613336 `" && echo ansible-tmp-1531261686.41-17595121613336="` echo /root/.ansible/tmp/ansible-tmp-1531261686.41-17595121613336 `" ) && sleep 0'
<localhost> EXEC /bin/sh -c 'echo ~root && sleep 0'
Using module file /usr/lib/python2.7/site-packages/ansible/modules/files/stat.py
<localhost> PUT /root/.ansible/tmp/ansible-local-1azbLzk/tmpNQHDX5 TO /root/.ansible/tmp/ansible-tmp-1531261686.41-17595121613336/stat.py
<localhost> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1531261686.41-17595121613336/ /root/.ansible/tmp/ansible-tmp-1531261686.41-17595121613336/stat.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python /root/.ansible/tmp/ansible-tmp-1531261686.41-17595121613336/stat.py && sleep 0'
<localhost> PUT /root/.ansible/tmp/ansible-local-1azbLzk/tmpexZUoE TO /root/.ansible/tmp/ansible-tmp-1531261686.41-17595121613336/source
<localhost> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1531261686.41-17595121613336/ /root/.ansible/tmp/ansible-tmp-1531261686.41-17595121613336/source && sleep 0'
Using module file /usr/lib/python2.7/site-packages/ansible/modules/files/copy.py
<localhost> PUT /root/.ansible/tmp/ansible-local-1azbLzk/tmpX2TBMT TO /root/.ansible/tmp/ansible-tmp-1531261686.41-17595121613336/copy.py
<localhost> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1531261686.41-17595121613336/ /root/.ansible/tmp/ansible-tmp-1531261686.41-17595121613336/copy.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python /root/.ansible/tmp/ansible-tmp-1531261686.41-17595121613336/copy.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1531261686.41-17595121613336/ > /dev/null 2>&1 && sleep 0'
changed: [localhost] => {
"changed": true,
"checksum": "607d0740ae706e7d42c9f296f93390c94ecd4ec0",
"dest": "/root/.aws/config",
"diff": [],
"gid": 0,
"group": "root",
"invocation": {
"module_args": {
"attributes": null,
"backup": false,
"checksum": "607d0740ae706e7d42c9f296f93390c94ecd4ec0",
"content": null,
"delimiter": null,
"dest": "/root/.aws/config",
"directory_mode": null,
"follow": false,
"force": true,
"group": null,
"local_follow": null,
"mode": null,
"original_basename": "tmpexZUoE",
"owner": null,
"regexp": null,
"remote_src": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"src": "/root/.ansible/tmp/ansible-tmp-1531261686.41-17595121613336/source",
"unsafe_writes": null,
"validate": null
}
},
"md5sum": "7b72a9804ed7e810b388c9e92cd25a02",
"mode": "0644",
"owner": "root",
"size": 51,
"src": "/root/.ansible/tmp/ansible-tmp-1531261686.41-17595121613336/source",
"state": "file",
"uid": 0
}
TASK [k8s_cluster : Generate aws profile credentials config] ***************
task path: /work/roles/k8s_cluster/tasks/auth.yml:13
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<localhost> EXEC /bin/sh -c 'echo ~root && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp/ansible-tmp-1531261687.07-195161353424403 `" && echo ansible-tmp-1531261687.07-195161353424403="` echo /root/.ansible/tmp/ansible-tmp-1531261687.07-195161353424403 `" ) && sleep 0'
<localhost> EXEC /bin/sh -c 'echo ~root && sleep 0'
Using module file /usr/lib/python2.7/site-packages/ansible/modules/files/stat.py
<localhost> PUT /root/.ansible/tmp/ansible-local-1azbLzk/tmpzMR7c4 TO /root/.ansible/tmp/ansible-tmp-1531261687.07-195161353424403/stat.py
<localhost> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1531261687.07-195161353424403/ /root/.ansible/tmp/ansible-tmp-1531261687.07-195161353424403/stat.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python /root/.ansible/tmp/ansible-tmp-1531261687.07-195161353424403/stat.py && sleep 0'
<localhost> PUT /root/.ansible/tmp/ansible-local-1azbLzk/tmp_TbjGz TO /root/.ansible/tmp/ansible-tmp-1531261687.07-195161353424403/source
<localhost> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1531261687.07-195161353424403/ /root/.ansible/tmp/ansible-tmp-1531261687.07-195161353424403/source && sleep 0'
Using module file /usr/lib/python2.7/site-packages/ansible/modules/files/copy.py
<localhost> PUT /root/.ansible/tmp/ansible-local-1azbLzk/tmpy6nZtq TO /root/.ansible/tmp/ansible-tmp-1531261687.07-195161353424403/copy.py
<localhost> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1531261687.07-195161353424403/ /root/.ansible/tmp/ansible-tmp-1531261687.07-195161353424403/copy.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python /root/.ansible/tmp/ansible-tmp-1531261687.07-195161353424403/copy.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1531261687.07-195161353424403/ > /dev/null 2>&1 && sleep 0'
changed: [localhost] => {
"changed": true,
"checksum": "fdd5709fcb09ffd1609526c4fb1b8c97af5a39bd",
"dest": "/root/.aws/credentials",
"diff": [],
"gid": 0,
"group": "root",
"invocation": {
"module_args": {
"attributes": null,
"backup": false,
"checksum": "fdd5709fcb09ffd1609526c4fb1b8c97af5a39bd",
"content": null,
"delimiter": null,
"dest": "/root/.aws/credentials",
"directory_mode": null,
"follow": false,
"force": true,
"group": null,
"local_follow": null,
"mode": null,
"original_basename": "tmp_TbjGz",
"owner": null,
"regexp": null,
"remote_src": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"src": "/root/.ansible/tmp/ansible-tmp-1531261687.07-195161353424403/source",
"unsafe_writes": null,
"validate": null
}
},
"md5sum": "58a27335e5096c98dcc080dee3661e60",
"mode": "0644",
"owner": "root",
"size": 128,
"src": "/root/.ansible/tmp/ansible-tmp-1531261687.07-195161353424403/source",
"state": "file",
"uid": 0
}
TASK [k8s_cluster : Ensure kubernetes config directory exists] *************
task path: /work/roles/k8s_cluster/tasks/auth.yml:18
Using module file /usr/lib/python2.7/site-packages/ansible/modules/files/file.py
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<localhost> EXEC /bin/sh -c 'echo ~root && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp/ansible-tmp-1531261687.43-91315504287353 `" && echo ansible-tmp-1531261687.43-91315504287353="` echo /root/.ansible/tmp/ansible-tmp-1531261687.43-91315504287353 `" ) && sleep 0'
<localhost> PUT /root/.ansible/tmp/ansible-local-1azbLzk/tmpa5UyJ0 TO /root/.ansible/tmp/ansible-tmp-1531261687.43-91315504287353/file.py
<localhost> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1531261687.43-91315504287353/ /root/.ansible/tmp/ansible-tmp-1531261687.43-91315504287353/file.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python /root/.ansible/tmp/ansible-tmp-1531261687.43-91315504287353/file.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1531261687.43-91315504287353/ > /dev/null 2>&1 && sleep 0'
changed: [localhost] => {
"changed": true,
"diff": {
"after": {
"path": "/root/.kube",
"state": "directory"
},
"before": {
"path": "/root/.kube",
"state": "absent"
}
},
"gid": 0,
"group": "root",
"invocation": {
"module_args": {
"attributes": null,
"backup": null,
"content": null,
"delimiter": null,
"diff_peek": null,
"directory_mode": null,
"follow": true,
"force": false,
"group": null,
"mode": null,
"original_basename": null,
"owner": null,
"path": "/root/.kube",
"recurse": false,
"regexp": null,
"remote_src": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"src": null,
"state": "directory",
"unsafe_writes": null,
"validate": null
}
},
"mode": "0755",
"owner": "root",
"path": "/root/.kube",
"size": 4096,
"state": "directory",
"uid": 0
}
TASK [k8s_cluster : Generate kubernetes client configuration] **************
task path: /work/roles/k8s_cluster/tasks/auth.yml:23
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<localhost> EXEC /bin/sh -c 'echo ~root && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp/ansible-tmp-1531261687.66-122329871464979 `" && echo ansible-tmp-1531261687.66-122329871464979="` echo /root/.ansible/tmp/ansible-tmp-1531261687.66-122329871464979 `" ) && sleep 0'
<localhost> EXEC /bin/sh -c 'echo ~root && sleep 0'
Using module file /usr/lib/python2.7/site-packages/ansible/modules/files/stat.py
<localhost> PUT /root/.ansible/tmp/ansible-local-1azbLzk/tmpZn7unt TO /root/.ansible/tmp/ansible-tmp-1531261687.66-122329871464979/stat.py
<localhost> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1531261687.66-122329871464979/ /root/.ansible/tmp/ansible-tmp-1531261687.66-122329871464979/stat.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python /root/.ansible/tmp/ansible-tmp-1531261687.66-122329871464979/stat.py && sleep 0'
<localhost> PUT /root/.ansible/tmp/ansible-local-1azbLzk/tmplPVzmk TO /root/.ansible/tmp/ansible-tmp-1531261687.66-122329871464979/source
<localhost> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1531261687.66-122329871464979/ /root/.ansible/tmp/ansible-tmp-1531261687.66-122329871464979/source && sleep 0'
Using module file /usr/lib/python2.7/site-packages/ansible/modules/files/copy.py
<localhost> PUT /root/.ansible/tmp/ansible-local-1azbLzk/tmpnkqANj TO /root/.ansible/tmp/ansible-tmp-1531261687.66-122329871464979/copy.py
<localhost> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1531261687.66-122329871464979/ /root/.ansible/tmp/ansible-tmp-1531261687.66-122329871464979/copy.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python /root/.ansible/tmp/ansible-tmp-1531261687.66-122329871464979/copy.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1531261687.66-122329871464979/ > /dev/null 2>&1 && sleep 0'
changed: [localhost] => {
"changed": true,
"checksum": "5497b7814ac8c31d437eb5a0ca26b02fdf838632",
"dest": "/root/.kube/config",
"diff": [],
"gid": 0,
"group": "root",
"invocation": {
"module_args": {
"attributes": null,
"backup": false,
"checksum": "5497b7814ac8c31d437eb5a0ca26b02fdf838632",
"content": null,
"delimiter": null,
"dest": "/root/.kube/config",
"directory_mode": null,
"follow": false,
"force": true,
"group": null,
"local_follow": null,
"mode": null,
"original_basename": "tmplPVzmk",
"owner": null,
"regexp": null,
"remote_src": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"src": "/root/.ansible/tmp/ansible-tmp-1531261687.66-122329871464979/source",
"unsafe_writes": null,
"validate": null
}
},
"md5sum": "15dda9e0e3766ae31062e2ca64591a91",
"mode": "0644",
"owner": "root",
"size": 1602,
"src": "/root/.ansible/tmp/ansible-tmp-1531261687.66-122329871464979/source",
"state": "file",
"uid": 0
}
TASK [k8s_cluster : Deploy the Traefik Daemonset] **************************
task path: /work/roles/k8s_cluster/tasks/main.yml:6
included: /work/roles/k8s_cluster/tasks/traefik.yml for localhost
TASK [k8s_cluster : Traefik Cluster Role] **********************************
task path: /work/roles/k8s_cluster/tasks/traefik.yml:3
Using module file /usr/lib/python2.7/site-packages/ansible/modules/clustering/k8s/k8s_raw.py
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<localhost> EXEC /bin/sh -c 'echo ~root && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp/ansible-tmp-1531261688.19-37398652026553 `" && echo ansible-tmp-1531261688.19-37398652026553="` echo /root/.ansible/tmp/ansible-tmp-1531261688.19-37398652026553 `" ) && sleep 0'
<localhost> PUT /root/.ansible/tmp/ansible-local-1azbLzk/tmppvk2jw TO /root/.ansible/tmp/ansible-tmp-1531261688.19-37398652026553/k8s_raw.py
<localhost> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1531261688.19-37398652026553/ /root/.ansible/tmp/ansible-tmp-1531261688.19-37398652026553/k8s_raw.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python /root/.ansible/tmp/ansible-tmp-1531261688.19-37398652026553/k8s_raw.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1531261688.19-37398652026553/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_VnpE5O/ansible_module_k8s_raw.py", line 163, in <module>
main()
File "/tmp/ansible_VnpE5O/ansible_module_k8s_raw.py", line 159, in main
KubernetesRawModule().execute_module()
File "/tmp/ansible_VnpE5O/ansible_modlib.zip/ansible/module_utils/k8s/raw.py", line 69, in __init__
File "/tmp/ansible_VnpE5O/ansible_modlib.zip/ansible/module_utils/k8s/common.py", line 128, in get_helper
File "/usr/lib/python2.7/site-packages/openshift/helper/base.py", line 52, in __init__
self.set_client_config(**auth)
File "/usr/lib/python2.7/site-packages/openshift/helper/base.py", line 115, in set_client_config
self.api_client = self.client_from_config(config_file, context)
File "/usr/lib/python2.7/site-packages/openshift/helper/kubernetes.py", line 19, in client_from_config
return config.new_client_from_config(config_file, context)
File "/usr/lib/python2.7/site-packages/kubernetes/config/kube_config.py", line 489, in new_client_from_config
persist_config=persist_config)
File "/usr/lib/python2.7/site-packages/kubernetes/config/kube_config.py", line 476, in load_kube_config
loader.load_and_set(client_configuration)
File "/usr/lib/python2.7/site-packages/kubernetes/config/kube_config.py", line 355, in load_and_set
self._load_cluster_info()
File "/usr/lib/python2.7/site-packages/kubernetes/config/kube_config.py", line 334, in _load_cluster_info
file_base_path=self._config_base_path).as_file()
File "/usr/lib/python2.7/site-packages/kubernetes/config/kube_config.py", line 100, in as_file
base64.decodestring(self._data.encode()))
File "/usr/lib/python2.7/base64.py", line 328, in decodestring
return binascii.a2b_base64(s)
binascii.Error: Incorrect padding
fatal: [localhost]: FAILED! => {
"changed": false,
"module_stderr": "Traceback (most recent call last):\n File \"/tmp/ansible_VnpE5O/ansible_module_k8s_raw.py\", line 163, in <module>\n main()\n File \"/tmp/ansible_VnpE5O/ansible_module_k8s_raw.py\", line 159, in main\n KubernetesRawModule().execute_module()\n File \"/tmp/ansible_VnpE5O/ansible_modlib.zip/ansible/module_utils/k8s/raw.py\", line 69, in __init__\n File \"/tmp/ansible_VnpE5O/ansible_modlib.zip/ansible/module_utils/k8s/common.py\", line 128, in get_helper\n File \"/usr/lib/python2.7/site-packages/openshift/helper/base.py\", line 52, in __init__\n self.set_client_config(**auth)\n File \"/usr/lib/python2.7/site-packages/openshift/helper/base.py\", line 115, in set_client_config\n self.api_client = self.client_from_config(config_file, context)\n File \"/usr/lib/python2.7/site-packages/openshift/helper/kubernetes.py\", line 19, in client_from_config\n return config.new_client_from_config(config_file, context)\n File \"/usr/lib/python2.7/site-packages/kubernetes/config/kube_config.py\", line 489, in new_client_from_config\n persist_config=persist_config)\n File \"/usr/lib/python2.7/site-packages/kubernetes/config/kube_config.py\", line 476, in load_kube_config\n loader.load_and_set(client_configuration)\n File \"/usr/lib/python2.7/site-packages/kubernetes/config/kube_config.py\", line 355, in load_and_set\n self._load_cluster_info()\n File \"/usr/lib/python2.7/site-packages/kubernetes/config/kube_config.py\", line 334, in _load_cluster_info\n file_base_path=self._config_base_path).as_file()\n File \"/usr/lib/python2.7/site-packages/kubernetes/config/kube_config.py\", line 100, in as_file\n base64.decodestring(self._data.encode()))\n File \"/usr/lib/python2.7/base64.py\", line 328, in decodestring\n return binascii.a2b_base64(s)\nbinascii.Error: Incorrect padding\n",
"module_stdout": "",
"msg": "MODULE FAILURE",
"rc": 1
}
to retry, use: --limit @/work/playbooks/k8s_virginia.retry
PLAY RECAP *********************************************************************
localhost : ok=7 changed=5 unreachable=0 failed=1
FROM williamyeh/ansible:alpine3
RUN apk add --no-cache \
gcc \
musl-dev \
python2-dev
RUN pip install --upgrade \
pip
WORKDIR /root
COPY requirements.txt .
RUN pip install --upgrade \
-r requirements.txt
ADD https://amazon-eks.s3-us-west-2.amazonaws.com/1.10.3/2018-06-05/bin/linux/amd64/heptio-authenticator-aws \
/root/heptio-authenticator-aws
RUN ln -s ~/heptio-authenticator-aws /usr/bin/
WORKDIR /work
VOLUME /work
---
- name: Set up kubernetes resources
roles: [ k8s_cluster ]
hosts: [ localhost ]
gather_facts: no
vars:
k8s_cluster_name: playpen
k8s_cluster_host: https://[redacted].sk1.us-east-1.eks.amazonaws.com
k8s_cluster_cacert: !vault |
$ANSIBLE_VAULT;1.1;AES256
[redacted]
aws_region: us-east-1
aws_access_key_id: [redacted]
aws_access_key_secret: !vault |
$ANSIBLE_VAULT;1.1;AES256
[redacted]
ansible
boto3
botocore
openshift
---
#apiVersion: rbac.authorization.k8s.io/v1beta1
apiVersion: v1beta1
kind: ClusterRole
metadata:
name: traefik-ingress-controller
rules:
- apiGroups: [ "" ]
resources: [ services, endpoints, secrets ]
verbs: [ get, list, watch ]
- apiGroups: [ extensions ]
resources: [ ingresses ]
verbs: [ get, list, watch ]
---
- name: Ensure aws config directory exists
file:
path: ~/.aws
state: directory
- name: Generate aws profile configuration
copy:
dest: ~/.aws/config
content: "{{ lookup('template', 'auth/aws_config.j2') }}"
- name: Generate aws profile credentials config
copy:
dest: ~/.aws/credentials
content: "{{ lookup('template', 'auth/aws_credentials.j2') }}"
- name: Ensure kubernetes config directory exists
file:
path: ~/.kube
state: directory
- name: Generate kubernetes client configuration
copy:
dest: ~/.kube/config
content: "{{ lookup('template', 'auth/kube_config.yml.j2') }}"
---
- name: Traefik Cluster Role
k8s_raw:
state: present
definition: "{{ lookup('file', 'traefik/clusterrole.k8s.yml') | from_yaml }}"
- name: Traefik Cluster Role Binding
k8s_raw:
state: present
definition: "{{ lookup('file', 'traefik/clusterrolebinding.k8s.yml') | from_yaml }}"
- name: Traefik Service Account
k8s_raw:
state: present
definition: "{{ lookup('file', 'traefik/serviceaccount.k8s.yml') | from_yaml }}"
- name: Traefik Daemonset
k8s_raw:
state: present
definition: "{{ lookup('file', 'traefik/daemonset.k8s.yml') | from_yaml }}"
- name: Traefik Ingress Service
k8s_raw:
state: present
definition: "{{ lookup('file', 'traefik/service_ingress.k8s.yml') | from_yaml }}"
- name: Traefik Web UI Service
k8s_raw:
state: present
definition: "{{ lookup('file', 'traefik/service_webui.k8s.yml') | from_yaml }}"
- name: Traefik Web UI Ingress
k8s_raw:
state: present
definition: "{{ lookup('file', 'traefik/ingress_webui.k8s.yml') | from_yaml }}"
[profile ansible]
output = json
region = {{ aws_region }}
[profile ansible]
aws_access_key_id = {{ aws_access_key_id }}
aws_secret_access_key = {{ aws_access_key_secret }}
apiVersion: v1
kind: Config
current-context: ansible
preferences: {}
contexts:
- name: ansible
context:
cluster: ansible
user: ansible
clusters:
- name: ansible
cluster:
server: {{ k8s_cluster_host }}
certificate-authority-data: >-
{{ k8s_cluster_cacert }}
users:
- name: ansible
user:
exec:
apiVersion: client.authentication.k8s.io/v1alpha1
command: heptio-authenticator-aws
args: [ token, -i, {{ k8s_cluster_name }} ]
env:
- { name: AWS_PROFILE, value: ansible }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment