Ansible-Playbook file only leading to error - "The following modules failed to execute: ansible.legacy.setup\n"

Viewed 5093

I have an Ansible-Playbook file that is supposed to create an apache2 server on localhost, create/copy some documents, install Git, and clone a repo. However, everytime I try to execute the file I keep getting this error:

fatal: [myserver]: FAILED! => {"ansible_facts": {}, "changed": false, "failed_modules": {"ansible.legacy.setup": {"failed": true, "module_stderr": "/usr/bin/env: ‘python’: No such file or directory\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 127}}, "msg": "The following modules failed to execute: ansible.legacy.setup\n"}

And this is my ansible-playbook file:

---
- hosts: myserver
  become: true
  remote_user: admin
  vars_files:
    - default.yml

  tasks:
    - name: Install Apache
      apt: name=apache2 update_cache=yes state=latest

- name: Create document root for domain
  file:
    path: "/var/www/{{ http_host }}"
    state: directory
    owner: "user"
    mode: '0755'

- name: Copy index page
  template:
    src: "index.html"
    dest: "/var/www/html/index.html"
    mode: '0755'

- name: Set up VirtualHost
  template:
    src: "apache2.conf"
    dest: "/etc/apache2/sites-available/{{ http_conf }}"
    mode: '0755'
  notify: restart-apache

- name: "HTTP on port {{ http_port }}"
  ufw:
    rule: allow
    port: "{{ http_port }}"
    proto: tcp

- name: Install Git
  apt:
    name: git
    state: present
    update_cache: yes

- name: Clone the repo
  ansible.builtin.git:
    repo: https://github.com/User/Repo
    dest: /home/user
    accept_hostkey: yes
    clone: yes
    update: yes
  become: no

  handlers:
    - name: restart-apache
      service:
        name: apache2
        state: restarted

I was originally testing this file on an Ubuntu VM, and it did work up until the task for cloning the repo. However, the VM I originally built this on got corrupted, so I had to create another Ubuntu VM and that's what I'm currently working on and where I am experiencing this issue.

I have ansible and python installed, so I don't think it's that.

What could the issue be?

0 Answers
Related