-1

I was trying to install htop on a debian server with this command:

ansible debian -m apt -a "name=htop state=present"

but I get this error:

ubuntu-20.lab | FAILED! => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python3"
    }, 
    "changed": false, 
    "msg": "'/usr/bin/apt-mark manual htop' failed: E: Could not create temporary file for /var/lib/apt/extended_states - mkstemp (13: Permission denied)\nE: Failed to write temporary StateFile /var/lib/apt/extended_states\n", 
    "rc": 100, 
    "stderr": "E: Could not create temporary file for /var/lib/apt/extended_states - mkstemp (13: Permission denied)\nE: Failed to write temporary StateFile /var/lib/apt/extended_states\n", 
    "stderr_lines": [
        "E: Could not create temporary file for /var/lib/apt/extended_states - mkstemp (13: Permission denied)", 
        "E: Failed to write temporary StateFile /var/lib/apt/extended_states"
    ], 
    "stdout": "", 
    "stdout_lines": []
}

I tried with -s but it says it's an unrecognized argument, is there another to have permission?

toydarian
  • 4,246
  • 5
  • 23
  • 35
  • 2
    seems like you do not have permission to do the installation ? To validate this, try installing the same by manually after loggin into the remote node. you may have to use `become/sudo` with sudo password – P.... Jun 11 '21 at 01:50
  • This is an OS privileges issue, not a programming issue. – Ken White Jun 11 '21 at 02:14

1 Answers1

5

You need to become root before installing anything on a debian machine using apt.

When using an ad-hoc (as you do) you do it like that, if you do not need a password for sudo: ansible debian -m apt -a "name=htop state=present" -b
If you need a password, you need to do this (so ansible will ask for the password first): ansible debian -m apt -a "name=htop state=present" -bK

If you start using playbooks, you can use -b or -bK as well, or you can add become: true to your playbook.

Check the documentation.

toydarian
  • 4,246
  • 5
  • 23
  • 35