Hi Karl, sure thing.
So I think I have the conditional working for the role, but not I’m stuck on testing that a directory exists. Here is the role.
`
filename: roles/bootstrap/ansible-bootstrap/tasks/configure.yml
- block:
- name: Check if Python is installed
raw: “[ -e {{ ansible_python_interpreter }} ] && echo ‘yes’ || echo ‘no’”
register: python_install
when: false
changed_when: false
-
name: Check if install tar file exists
raw: “[ -e /tmp/pypy-{{ pypy_version }}.tar.bz2 ] && echo ‘/tmp/pypy-{{ pypy_version }}.tar.bz2’ || echo ""”
register: pypy_tar_file
when: false
-
name: Check if pypy directory exists
raw: “[ -e {{ pypy_dir }} ] && echo ‘{{ pypy_dir }}’ || echo ""”
register: pypy_directory
when: false
-
name: Check if libtinfo is simlinked
raw: “[ -e {{ pypy_dir }}/lib/libtinfo.so.5 ] && echo ‘{{ pypy_dir }}/lib/libtinfo.so.5’ || echo ""”
register: libtinfo_symlink
when: false
ignore_errors: yes
-
name: Download PyPy
raw: wget -O /tmp/pypy-{{ pypy_version }}.tar.bz2 https://bitbucket.org/pypy/pypy/downloads/pypy-{{ pypy_version }}-linux64.tar.bz2
when: pypy_tar_file.stdout == “”
-
name: Extract PyPy
raw: mkdir -p {{ pypy_dir }} && tar xf /tmp/pypy-{{ pypy_version }}.tar.bz2 -C {{ pypy_dir }}/ --strip-components=1
args:
warn: false
when: pypy_directory.stdout == “”
-
name: Symlink libncurses as libtinfo.so.5
raw: mkdir -p {{ pypy_dir }}/lib && ln -s /lib64/libncurses.so.5.9 {{ pypy_dir }}/lib/libtinfo.so.5
args:
warn: false
when: libtinfo_symlink.stdout == “”
-
name: Install PyPy
script: bootstrap.sh {{ pypy_dir }} {{ ansible_python_interpreter }}
when: python_install.stdout == ‘yes’
`
The error message seems to implicate the ansible_python_interpreter
variable, since it has the path /home/core/bin/python
.
I’ve also tried this popular variation:
`
- name: Check if Python is installed
stat:
path: ansible_python_interpreter
register: python_install
when: false
`
And updated the when at the bottom. Also tried using - debug
.
`
when: file_details.stat.exists
`
No matter what I do, the output is always the same, which leads me to conclude the error must be somewhere else, but I can’t see where else it could be coming from. Is it because everything above it was skipped?
`
Bringing machine ‘etcd-01’ up with ‘virtualbox’ provider…
Bringing machine ‘kube-master-01’ up with ‘virtualbox’ provider…
Bringing machine ‘kube-worker-01’ up with ‘virtualbox’ provider…
Bringing machine ‘kube-worker-02’ up with ‘virtualbox’ provider…
==> etcd-01: Checking if box ‘coreos-stable’ is up to date…
==> etcd-01: [vagrant-hostmanager:guests] Updating hosts file on active guest virtual machines…
==> etcd-01: Machine already provisioned. Run vagrant provision
or use the --provision
==> etcd-01: flag to force provisioning. Provisioners marked to run always will still run.
==> kube-master-01: Checking if box ‘coreos-stable’ is up to date…
==> kube-master-01: [vagrant-hostmanager:guests] Updating hosts file on active guest virtual machines…
==> kube-master-01: Machine already provisioned. Run vagrant provision
or use the --provision
==> kube-master-01: flag to force provisioning. Provisioners marked to run always will still run.
==> kube-worker-01: Checking if box ‘coreos-stable’ is up to date…
==> kube-worker-01: [vagrant-hostmanager:guests] Updating hosts file on active guest virtual machines…
==> kube-worker-01: Machine already provisioned. Run vagrant provision
or use the --provision
==> kube-worker-01: flag to force provisioning. Provisioners marked to run always will still run.
==> kube-worker-02: Checking if box ‘coreos-stable’ is up to date…
==> kube-worker-02: [vagrant-hostmanager:guests] Updating hosts file on active guest virtual machines…
==> kube-worker-02: Machine already provisioned. Run vagrant provision
or use the --provision
==> kube-worker-02: flag to force provisioning. Provisioners marked to run always will still run.
PLAY [Bootstrap coreos hosts] **********************************************************************************************************************************************************
TASK [bootstrap/ansible-bootstrap : Check if Python is installed] **********************************************************************************************************************
skipping: [kube-master-01]
skipping: [etcd-01]
skipping: [kube-worker-01]
skipping: [kube-worker-02]
TASK [bootstrap/ansible-bootstrap : Check if install tar file exists] ******************************************************************************************************************
skipping: [kube-master-01]
skipping: [etcd-01]
skipping: [kube-worker-01]
skipping: [kube-worker-02]
TASK [bootstrap/ansible-bootstrap : Check if pypy directory exists] ********************************************************************************************************************
skipping: [kube-master-01]
skipping: [etcd-01]
skipping: [kube-worker-01]
skipping: [kube-worker-02]
TASK [bootstrap/ansible-bootstrap : Check if libtinfo is simlinked] ********************************************************************************************************************
skipping: [kube-master-01]
skipping: [etcd-01]
skipping: [kube-worker-01]
skipping: [kube-worker-02]
TASK [bootstrap/ansible-bootstrap : Download PyPy] *************************************************************************************************************************************
skipping: [kube-master-01]
skipping: [etcd-01]
skipping: [kube-worker-01]
skipping: [kube-worker-02]
TASK [bootstrap/ansible-bootstrap : Extract PyPy] **************************************************************************************************************************************
skipping: [kube-master-01]
skipping: [etcd-01]
skipping: [kube-worker-01]
skipping: [kube-worker-02]
TASK [bootstrap/ansible-bootstrap : Symlink libncurses as libtinfo.so.5] ***************************************************************************************************************
skipping: [kube-master-01]
skipping: [etcd-01]
skipping: [kube-worker-01]
skipping: [kube-worker-02]
TASK [bootstrap/ansible-bootstrap : Install PyPy] **************************************************************************************************************************************
skipping: [kube-master-01]
skipping: [etcd-01]
skipping: [kube-worker-01]
skipping: [kube-worker-02]
TASK [bootstrap/ansible-bootstrap : Test if Python is installed] ***********************************************************************************************************************
skipping: [kube-master-01]
skipping: [etcd-01]
skipping: [kube-worker-01]
skipping: [kube-worker-02]
TASK [bootstrap/ansible-bootstrap : Gather ansible facts] ******************************************************************************************************************************
skipping: [kube-master-01]
skipping: [etcd-01]
skipping: [kube-worker-01]
skipping: [kube-worker-02]
PLAY [Create certificates for Kubernetes componentes] **********************************************************************************************************************************
TASK [Gathering Facts] *****************************************************************************************************************************************************************
fatal: [etcd-01]: FAILED! => {“changed”: false, “module_stderr”: “Connection to 127.0.0.1 closed.\r\n”, “module_stdout”: “/bin/sh: /home/core/bin/python: No such file or directory\r\n”, “msg”: “MODULE FAILURE”, “rc”: 127}
fatal: [kube-worker-01]: FAILED! => {“changed”: false, “module_stderr”: “Connection to 127.0.0.1 closed.\r\n”, “module_stdout”: “/bin/sh: /home/core/bin/python: No such file or directory\r\n”, “msg”: “MODULE FAILURE”, “rc”: 127}
fatal: [kube-master-01]: FAILED! => {“changed”: false, “module_stderr”: “Connection to 127.0.0.1 closed.\r\n”, “module_stdout”: “/bin/sh: /home/core/bin/python: No such file or directory\r\n”, “msg”: “MODULE FAILURE”, “rc”: 127}
fatal: [kube-worker-02]: FAILED! => {“changed”: false, “module_stderr”: “Connection to 127.0.0.1 closed.\r\n”, “module_stdout”: “/bin/sh: /home/core/bin/python: No such file or directory\r\n”, “msg”: “MODULE FAILURE”, “rc”: 127}
PLAY RECAP *****************************************************************************************************************************************************************************
etcd-01 : ok=0 changed=0 unreachable=0 failed=1
kube-master-01 : ok=0 changed=0 unreachable=0 failed=1
kube-worker-01 : ok=0 changed=0 unreachable=0 failed=1
kube-worker-02 : ok=0 changed=0 unreachable=0 failed=1
`
This is the repo I’ve been working from: https://github.com/sebiwi/kubernetes-coreos
Starts with the Makefile, then enters kubernetes.yml, and the subject of concern is the very first role listed.