[ansible]apt update && apt install tree

This can be applied to install package from apt repo.
I have three ubuntu servers under the group linux.

YAML file

- hosts: linux
  become: true
  become_user: root
   - name: apt update && apt install tree -y
       update_cache: yes
       name: tree
       state: present

Reference: https://docs.ansible.com/ansible/latest/modules/apt_module.html


The ansible python script is sent from the control node to the ubuntu servers, this is the default behaviour, unless the connection is like network_cli then the control node executes ssh to the network device which does not have python to execute the playbook.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s