0

I am using molecule to test ansible playbooks. The image i have has python2 with a symlink of /usr/bin/python -> /usr/bin/python2.7. In my prepare.yml, i have the following

    - name: Install python3 package
      package:
        name:
          - python3

    - name: Remove python2 symlink
      file:
        path: /usr/bin/python
        state: absent

    - name: Add python3 symlink
      file:
        src: /opt/python3/bin/python3.7
        dest: /usr/bin/python
        state: link

When I run this, the python3 package is successfully installed, the /usr/bin/python is removed, but it fails to create the symlink. This is presumably because i removed the python interpreter. Any suggestions on how to resolve this?

  • Are there any logs that you can share to help diagnose the issue? The only thing we have to go on now is that a symlink doesn't exist at /usr/bin/python – SargeATM Aug 22 '22 at 23:51

1 Answers1

0

A shot in the dark, but what if you remove the name: Remove python2 symlink section?

- name: Install python3 package
  package:
    name:
      - python3

- name: Change python symlink to point to python3.7
  file:
    src: /opt/python3/bin/python3.7
    dest: /usr/bin/python
    state: link
SargeATM
  • 2,483
  • 14
  • 24