play-iot / iot-vpn

Play-iO IIoT VPN
Apache License 2.0
6 stars 0 forks source link

run ansible playbook against hosts with python3 installed by default #77

Closed anhcq151 closed 3 years ago

anhcq151 commented 3 years ago

Describe the bug In Ubuntu 16.04 and later, python3 is installed by default and python2 is removed, this leads to missing default python interpreter used by ansible /usr/bin/python on such hosts and the play is failed with message:

bash: /usr/bin/python: No such file or directory

Version Latest (or any) version of vpnc-deployer-cli

To Reproduce Run the ansible playbook against any linux distro with python3 installed by default, such as: Ubuntu 18.04, Ubuntu 20.04...

Expected behavior The ansible playbook should be able to resolve this scenario

anhcq151 commented 3 years ago

Proposed methods to remediate this issue:

  1. Set ansible_python_interpreter: /usr/bin/python3 variable for all hosts that have python3 installed by default
    • Pros: No changes are required on target hosts
    • Cons: We need to know for sure the target hosts have python3 installed by default else the play will failed
  2. Symlink /usr/bin/python3 to /usr/bin/python using Ansible’s raw module
    • Pros: No changes are required on target hosts
    • Cons: We need to add or include this play at the top of all our playbooks, which adds unnecessary duplication and may be a source of errors.
    • name: symlink /usr/bin/python -> /usr/bin/python3 hosts: all gather_facts: false tasks:
    • name: symlink /usr/bin/python -> /usr/bin/python3 raw: | if [ -f /usr/bin/python3 ] && [ ! -f /usr/bin/python ]; then ln --symbolic /usr/bin/python3 /usr/bin/python; fi become: true