0

If Im trying to install any packages from awx console using ansible playbook ,which pull it from git.

But its giving the below error in local ubuntu machine.

/bin/sh: apt: command not found", "stderr_lines": ["/bin/sh: apt: command not found"], "stdout": "", "stdout_lines

or sometimes.

changed": false, "cmd": "apt-get update", "msg": "[Errno 2] No such file or directory", "rc

its working with yum package but not with opt package ,what might be the reason , please help on this.

If Im trying to install any packages from awx console using ansible playbook ,which pulls it from github.


  • hosts: all become: yes become_method: sudo tasks:
    • name: ensure apache is at the latest version apt: name={{ item }} update_cache=yes with_items:
      • apache2

/bin/sh: apt: command not found", "stderr_lines": ["/bin/sh: apt: command not found"], "stdout": "", "stdout_lines

nandeesh b
  • 11
  • 1
  • 2

1 Answers1

0

Change your code to:

---
- hosts: all 
  become: True 
  tasks:
    - name: ensure apache is at the latest version 
      yum: 
        name: "{{ item }}" 
      update_cache: yes 
      with_items:
        - apache2

Your distribution does not has APT installed, which is the package manager. You're most likely on CentOS, which uses YUM as the package manager.

You should not use apt, use yum instead

--EDIT--

There could be a couple of issues going on. First we'll verify if you have targeted the correct machine. Can you run this Ansible playbook:

---
- hosts: all 
  become: True 
  tasks:
    - name: test
      shell: touch /tmp/file.txt

    - name: ip address of targeted nodes
      debug: var=hostvars[inventory_hostname]['ansible_default_ipv4']['address']

Now, connect to your AWS node and can you verify the file is at /tmp/file.txt.

On the node itself, what happens when you run the commands yum and apt.

Also, run ip -a on your Ubuntu node, and verify the IP addresses match.

If APT is really missing, then you should reïnstall your machine. Because of this

Kevin C
  • 4,851
  • 8
  • 30
  • 64
  • No im using ubuntu machine and awx is running on local machine which on ubuntu 18.04 ,not in centos. – nandeesh b Feb 13 '19 at 09:29
  • can you perform "cat /etc/*release" and paste the output on pastebin or something. – Kevin C Feb 13 '19 at 10:33
  • nandeesh@host:~$ cat /etc/*release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=18.04 DISTRIB_CODENAME=bionic DISTRIB_DESCRIPTION="Ubuntu 18.04.2 LTS" NAME="Ubuntu" VERSION="18.04.2 LTS (Bionic Beaver)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 18.04.2 LTS" VERSION_ID="18.04" HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" VERSION_CODENAME=bionic UBUNTU_CODENAME=bionic – nandeesh b Feb 14 '19 at 05:17