Agentless automation is easiest when one control node can reach the rest of your lab over SSH and push changes without extra daemons or agents. That is exactly what you get when you install Ansible on Ubuntu Linux, whether you want quick ad hoc commands for a single server or repeatable playbooks for a larger fleet.
Ubuntu 26.04 already ships a current Ansible package, older supported LTS releases have newer-source options, and pipx remains the clean fallback when you want Ansible outside the system Python stack. A small local inventory, a project ansible.cfg, and first ping and playbook runs get the control node ready before you point it at real hosts.
Install Ansible on Ubuntu
Ansible runs on the control node only. Managed nodes normally just need SSH access and Python available for the modules that execute remotely.
Update Ubuntu Before Installing Ansible
Refresh package metadata first so Ubuntu sees the latest repository state before you choose a package source.
sudo apt update && sudo apt upgrade
These commands use
sudofor package-management tasks. If your account is not in the sudoers file yet, follow the guide to add a new user to sudoers on Ubuntu first.
Choose Your Ansible Installation Method on Ubuntu
Use the package source that matches your Ubuntu release and how closely you want Ansible tied to the system Python stack.
| Method | Channel | Version | Updates | Best For |
|---|---|---|---|---|
| Ubuntu repositories (26.04) | Ubuntu package search | Distribution default | Automatic via APT | Ubuntu 26.04 users who want distro-managed packages |
| Ansible PPA (24.04/22.04) | Launchpad PPA | Latest supported branch | Automatic via APT | Ubuntu 24.04 and 22.04 users who want newer packages without manual Python setup |
| pipx | pipx / PyPI | Latest supported Python package | pipx upgrade --include-injected ansible | Any supported Ubuntu LTS release when you want a user-space install |
For most users, pick the APT method that matches your Ubuntu release. It keeps Ansible inside Ubuntu’s normal package workflow and avoids extra PATH cleanup later.
Ubuntu 26.04 does not have Ansible PPA builds yet. Use Ubuntu’s packaged Ansible or the
pipxmethod on 26.04 for now; once the Ansible team publishesresolutepackages, the regular PPA path becomes viable there as well.
Install Ansible from Ubuntu Repositories on Ubuntu 26.04
Ubuntu 26.04 already carries Ansible 13.1.x in universe, so the shortest path is the native package. The commands below install the full ansible package instead of the smaller ansible-core runtime so you start with the curated collections Ansible expects out of the box.
sudo apt install ansible -y
Confirm that APT pulled the package from Ubuntu 26.04 itself:
apt-cache policy ansible
ansible:
Installed: 13.1.0+dfsg-1
Candidate: 13.1.0+dfsg-1
Version table:
*** 13.1.0+dfsg-1 500
500 http://au.archive.ubuntu.com/ubuntu resolute/universe amd64 Packages
100 /var/lib/dpkg/status
Then verify the CLI itself:
ansible --version
ansible [core 2.20.1] config file = None configured module search path = ['/home/linuxcapable/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /usr/lib/python3/dist-packages/ansible ansible collection location = /home/linuxcapable/.ansible/collections:/usr/share/ansible/collections executable location = /usr/bin/ansible
Your home-directory path reflects your own username. It is normal for the first check to show config file = None until you create a project or home-directory ansible.cfg.
Install Ansible from the Ansible PPA on Ubuntu 24.04 and 22.04
The official Ubuntu instructions in the Ansible documentation use the Ansible team PPA. It is the practical choice on Ubuntu 24.04 and 22.04 when you want a newer branch than the version in Ubuntu’s own repositories.
Most desktop installs already provide add-apt-repository. Minimal, server, and cloud images often need software-properties-common first.
sudo apt install software-properties-common -y
Add the PPA and let Ubuntu refresh APT immediately. The add-apt-repository command writes the right source-file format for your release, so Ubuntu 24.04 can use a .sources file while Ubuntu 22.04 can still use the older .list layout.
sudo add-apt-repository --yes --update ppa:ansible/ansible
Get:6 https://ppa.launchpadcontent.net/ansible/ansible/ubuntu noble InRelease [17.8 kB] Get:7 https://ppa.launchpadcontent.net/ansible/ansible/ubuntu noble/main amd64 Packages [772 B] Get:8 https://ppa.launchpadcontent.net/ansible/ansible/ubuntu noble/main Translation-en [472 B] Fetched 19.0 kB in 3s (7,507 B/s) Reading package lists...
Install the full Ansible package from the PPA:
sudo apt install ansible -y
Use apt-cache policy to confirm Ubuntu now prefers the PPA build:
apt-cache policy ansible
ansible:
Installed: 13.4.0-1ppa~noble
Candidate: 13.4.0-1ppa~noble
Version table:
*** 13.4.0-1ppa~noble 500
500 https://ppa.launchpadcontent.net/ansible/ansible/ubuntu noble/main amd64 Packages
100 /var/lib/dpkg/status
9.2.0+dfsg-0ubuntu5 500
500 http://au.archive.ubuntu.com/ubuntu noble/universe amd64 Packages
Check the community package version as well:
ansible-community --version
Ansible community version 13.4.0
Ubuntu 22.04 uses the same commands, but the resulting package is older: the PPA currently installs Ansible 10.7.0 with ansible-core 2.17.14 on Jammy. That still tracks far ahead of Ubuntu 22.04’s own universe package.
Install Ansible with pipx on Ubuntu 26.04, 24.04, and 22.04
The official Ansible documentation also supports pipx. It creates a dedicated virtual environment for Ansible under your home directory, keeps the CLI available in ~/.local/bin, and avoids mixing Ansible with Ubuntu’s system Python packages.
sudo apt install pipx -y
Make sure future shell sessions can find the pipx application directory:
pipx ensurepath
/home/linuxcapable/.local/bin has been added to PATH, but you need to open a new terminal or re-login for this PATH change to take effect. Alternatively, you can source your shell's config file with e.g. 'source ~/.bashrc'. You will need to open a new terminal or re-login for the PATH changes to take effect. Alternatively, you can source your shell's config file with e.g. 'source ~/.bashrc'.
If you do not want to reopen the shell yet, use the full path shown in the next verification step for the rest of the current session. If you would rather manage Ansible inside a project-specific environment instead, create Python virtual environments on Ubuntu and install the Python package there instead.
Install the full Ansible package with all exposed helper commands. The --include-deps flag makes tools such as ansible-galaxy, ansible-playbook, and ansible-vault available alongside the main ansible entry point.
pipx install --include-deps ansible
Verify the pipx-managed Ansible binary directly:
~/.local/bin/ansible --version
ansible [core 2.20.3] config file = None configured module search path = ['/home/linuxcapable/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /home/linuxcapable/.local/share/pipx/venvs/ansible/lib/python3.14/site-packages/ansible ansible collection location = /home/linuxcapable/.ansible/collections:/usr/share/ansible/collections executable location = /home/linuxcapable/.local/bin/ansible
The home-directory path and Python minor version vary by username and Ubuntu release. Ubuntu 24.04 shows Python 3.12 in the same output, and Ubuntu 22.04 shows Python 3.10.
Then confirm the community package version:
~/.local/bin/ansible-community --version
Ansible community version 13.4.0
Ubuntu 24.04 installs the same 13.4.x branch through pipx today. Ubuntu 22.04 installs 10.7.x instead, because the newest Ansible releases require a newer Python than Jammy ships by default.
Compare Ansible Versions on Ubuntu
The install method matters most on Ubuntu 24.04 and 22.04, where the repository branch and the PPA or pipx branch are far apart.
| Ubuntu Release | Ubuntu Repositories | Ansible PPA | pipx | What This Means |
|---|---|---|---|---|
| Ubuntu 26.04 | Ansible 13.1.x / core 2.20.x | Not published yet | Ansible 13.4.x / core 2.20.x | Use Ubuntu’s package when you want native packaging, or pipx when you want the newest Python release. |
| Ubuntu 24.04 | Ansible 9.2.x / core 2.16.x | Ansible 13.4.x / core 2.20.x | Ansible 13.4.x / core 2.20.x | The PPA or pipx gives you the current branch without moving off Ubuntu 24.04. |
| Ubuntu 22.04 | Ansible 2.10.x / core 2.12.x | Ansible 10.7.x / core 2.17.x | Ansible 10.7.x / core 2.17.x | Ubuntu 22.04 stays on an older but still maintained branch because its default Python is 3.10. |
If you migrate playbooks from Ubuntu 22.04 to 24.04 or 26.04, validate them before you assume newer branches behave the same. Ansible 12 and ansible-core 2.19 introduced templating changes that can expose older playbook assumptions.
Get Started with Ansible on Ubuntu
Keep your first tests local. That lets you verify inventory, configuration, and module execution before you point Ansible at a remote host.
Create an Inventory for Ansible on Ubuntu
Create a small project directory and a one-host inventory that targets the local machine.
mkdir -p ~/ansible-lab
cd ~/ansible-lab
printf '%s\n' '[local]' 'localhost ansible_connection=local' > inventory.ini
Check that Ansible can read the inventory structure. Because the project ansible.cfg does not exist yet, pass the inventory file explicitly for this first check:
ansible-inventory -i inventory.ini --graph
@all: |--@ungrouped: |--@local: | |--localhost
Create an ansible.cfg File on Ubuntu
Keep project defaults beside the inventory so each automation directory carries its own settings.
printf '%s\n' '[defaults]' 'inventory = ./inventory.ini' 'forks = 10' 'interpreter_python = auto_silent' > ansible.cfg
The inventory line makes your project inventory the default, forks = 10 raises parallelism for larger batches, and interpreter_python = auto_silent lets Ansible discover the right Python on managed nodes without repeated warnings.
Confirm that Ansible is loading the project file and the settings you changed:
ansible-config dump --only-changed
CONFIG_FILE() = /home/linuxcapable/ansible-lab/ansible.cfg DEFAULT_FORKS(/home/linuxcapable/ansible-lab/ansible.cfg) = 10 DEFAULT_HOST_LIST(/home/linuxcapable/ansible-lab/ansible.cfg) = ['/home/linuxcapable/ansible-lab/inventory.ini'] INTERPRETER_PYTHON(/home/linuxcapable/ansible-lab/ansible.cfg) = auto_silent GALAXY_SERVERS:
Those file paths reflect the current username and project directory, so your own output points at your home directory instead of /home/linuxcapable.
Run Your First Ansible Command on Ubuntu
The ping module checks that Ansible can talk to the target and execute Python there. It is not an ICMP network ping.
ansible all -m ansible.builtin.ping
localhost | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python3.14"
},
"changed": false,
"ping": "pong"
}
Run Your First Ansible Playbook on Ubuntu
Create a minimal playbook that reuses the same inventory and runs the same module through the playbook engine.
printf '%s\n' '---' '- name: Test local connectivity' ' hosts: local' ' gather_facts: false' ' tasks:' ' - name: Run the ping module' ' ansible.builtin.ping:' > ping.yml
Execute the playbook:
ansible-playbook ping.yml
PLAY [Test local connectivity] ************************************************* TASK [Run the ping module] ***************************************************** ok: [localhost] PLAY RECAP ********************************************************************* localhost : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
Configure Ansible on Ubuntu
Most users can stay close to the defaults, but a few settings are worth understanding once you move beyond a one-host test.
Understand Ansible Configuration Precedence on Ubuntu
Ansible uses the first configuration file it finds, then layers higher-precedence settings on top. For predictable projects, keep the configuration beside the inventory and playbooks you actually run.
ANSIBLE_CONFIGif you export it explicitly./ansible.cfgin the current working directory~/.ansible.cfgin your home directory/etc/ansible/ansible.cfgwhen the installed package provides it
Environment variables override the loaded configuration file, and command-line options override both. That makes a project-local ansible.cfg the safest default when you want repeatable behavior across shells and hosts.
Ansible will not auto-load ./ansible.cfg from a world-writable directory. If you keep playbooks on a shared or synced path, move the project into a normal home-directory folder or export ANSIBLE_CONFIG deliberately.
Useful ansible.cfg Options for Ubuntu Control Nodes
These are the settings most Ubuntu control nodes end up adjusting first:
inventory: sets the default inventory path so you do not need-ion every command.forks: controls how many hosts Ansible handles in parallel.interpreter_python = auto_silent: discovers the correct Python on managed nodes without noisy warnings.remote_user: sets the default SSH user when most of your targets use the same account.timeout: raises or lowers the SSH connection wait for slow links or busy hosts.
Prepare Ubuntu Managed Nodes for Ansible
Managed Ubuntu nodes do not need Ansible installed unless they also act as another control node. In most cases they just need SSH access, Python, and an account with the permissions your playbooks expect.
If a target host does not accept SSH yet, install SSH on Ubuntu first. If SSH is running but still blocked, configure UFW on Ubuntu to allow the right port. If you still need an administrative account for remote tasks, follow the guide to configure sudo access on Ubuntu before you start pushing privileged changes.
Update or Remove Ansible on Ubuntu
The update path depends on how you installed Ansible. Keep package-managed installs on APT, and keep pipx installs inside pipx.
Update Ansible Package Installs on Ubuntu
Use the same APT command whether Ansible came from Ubuntu 26.04 or the Ansible PPA on Ubuntu 24.04 and 22.04.
sudo apt update && sudo apt install --only-upgrade ansible ansible-core -y
Reading package lists... Building dependency tree... Reading state information... ansible is already the newest version (13.1.0+dfsg-1). ansible-core is already the newest version (2.20.1-1). Solving dependencies... Summary: Upgrading: 0, Installing: 0, Removing: 0, Not Upgrading: 17
Ubuntu 24.04 and 22.04 show different version numbers here, but the update command stays the same. APT simply follows the package source you configured for that release, whether that is Ubuntu 26.04’s repo build or the Ansible PPA on the older LTS releases.
Update Ansible pipx Installs on Ubuntu
Upgrade the pipx environment in place when you installed Ansible as a user-space application.
pipx upgrade --include-injected ansible
upgrading shared libraries... upgrading ansible... ansible is already at latest version 13.4.0 (location: /home/linuxcapable/.local/share/pipx/venvs/ansible)
Ubuntu 24.04 uses the same ~/.local/share/pipx/venvs layout here. Ubuntu 22.04 can still show the older ~/.local/pipx/venvs path depending on the installed pipx version, but the upgrade workflow is the same.
Remove Ansible Package Installs on Ubuntu
Remove the package and any unneeded dependencies first.
sudo apt remove --purge ansible ansible-core -y
sudo apt autoremove -y
If you used the PPA on Ubuntu 24.04 or 22.04, remove that source as well so future APT refreshes stop checking it.
sudo add-apt-repository --yes --remove ppa:ansible/ansible && sudo apt update
Confirm that the package is gone. On Ubuntu 26.04 the candidate falls back to Ubuntu’s 13.1.x build. Ubuntu 24.04 falls back to Noble’s 9.2.x package, and Ubuntu 22.04 falls back to Jammy’s 2.10.x package.
apt-cache policy ansible
ansible:
Installed: (none)
Candidate: 13.1.0+dfsg-1
Version table:
13.1.0+dfsg-1 500
500 http://au.archive.ubuntu.com/ubuntu resolute/universe amd64 Packages
Package removal does not delete project files or user data. Remove
~/ansible-labif you created it, and review~/.ansiblebefore deleting it, because that directory can hold collections, inventory caches, vault material, and plugin data.
Remove Ansible pipx Installs on Ubuntu
Remove the pipx application bundle when you no longer want the user-space install.
pipx uninstall ansible
Check that the exposed executable is gone:
ls ~/.local/bin/ansible
ls: cannot access '/home/linuxcapable/.local/bin/ansible': No such file or directory
Your path will reflect your own home directory, not /home/linuxcapable. The missing-file message is what matters.
The uninstall does not remove the PATH lines that pipx ensurepath added to your shell startup files. The pipx tool also keeps its own cache and metadata directories under ~/.cache/pipx and ~/.local/share/pipx, and Ansible can still leave ~/.ansible behind after you start using it. Remove only the pieces you no longer need.
Ansible on Ubuntu FAQ
Most Ubuntu users should start with ansible. It includes ansible-core plus a curated collection set, so you can run common modules and playbooks immediately. Use ansible-core only when you intentionally want the smaller runtime and plan to add collections yourself.
No. Ubuntu 26.04 already ships Ansible 13.1.x in its own universe repository, so the native package is the simplest APT-based path today. The Ansible PPA does not publish resolute builds yet, so use Ubuntu’s package or the pipx method on 26.04.
No. In normal SSH-based automation, only the control node needs Ansible installed. Managed Ubuntu hosts usually just need Python and SSH access. If a target machine still needs the server side of SSH, set up SSH on Ubuntu before you start running playbooks against it.
Ubuntu 22.04 ships Python 3.10 by default, and that limits both the PPA and pipx to the newest Ansible branch that still supports that interpreter. Today that means Ansible 10.7.x with ansible-core 2.17.x on 22.04, while Ubuntu 24.04 and 26.04 can run the newer 13.x branch.
Conclusion
Ansible is ready on Ubuntu Linux for inventories, ad hoc commands, and first playbooks through either APT or pipx. Keep a project-level ansible.cfg beside your inventory, then enable SSH on Ubuntu on the managed side and expand from the local ping test into real host automation.
Formatting tips for your comment
You can use basic HTML to format your comment. Useful tags currently allowed:
<code>command</code>command<strong>bold</strong><em>italic</em><blockquote>quote</blockquote>