Zum Hauptinhalt springen
Unix & Linux ServerDistribution Release: Qubes OS 4.3.2(03.10.2026 um 00:03 Uhr)
•
Linux Tipps & HardeningSecurity: Mehrere Probleme in redis (Debian)(03.10.2026 um 01:01 Uhr)
•
Sichere ProgrammierungCopilot code review: API support and new default effort level(02.10.2026 um 21:13 Uhr)
•
Sichere ProgrammierungStateless GitHub App installation tokens rolled out(03.10.2026 um 00:18 Uhr)
•
Sichere ProgrammierungWe Tried ISO-AdamW. AdamW Kept Its Job.(03.10.2026 um 00:08 Uhr)
•
Sichere ProgrammierungClaim Ledger gives a project review a paper trail(03.10.2026 um 00:10 Uhr)
••
Sichere ProgrammierungWhat getting into thirteen database projects' docs actually took(03.10.2026 um 00:11 Uhr)
•
Sichere ProgrammierungYour security gate always passes. Can it actually block a release?(03.10.2026 um 00:11 Uhr)
•
Sichere Programmierung🚀 Starting my Hacktoberfest journey!(03.10.2026 um 00:12 Uhr)
•
Unix & Linux ServerDistribution Release: Qubes OS 4.3.2(03.10.2026 um 00:03 Uhr)
•
Linux Tipps & HardeningSecurity: Mehrere Probleme in redis (Debian)(03.10.2026 um 01:01 Uhr)
•
Sichere ProgrammierungCopilot code review: API support and new default effort level(02.10.2026 um 21:13 Uhr)
•
Sichere ProgrammierungStateless GitHub App installation tokens rolled out(03.10.2026 um 00:18 Uhr)
•
Sichere ProgrammierungWe Tried ISO-AdamW. AdamW Kept Its Job.(03.10.2026 um 00:08 Uhr)
•
Sichere ProgrammierungClaim Ledger gives a project review a paper trail(03.10.2026 um 00:10 Uhr)
••
Sichere ProgrammierungWhat getting into thirteen database projects' docs actually took(03.10.2026 um 00:11 Uhr)
•
Sichere ProgrammierungYour security gate always passes. Can it actually block a release?(03.10.2026 um 00:11 Uhr)
•
Sichere Programmierung🚀 Starting my Hacktoberfest journey!(03.10.2026 um 00:12 Uhr)
•
Intelligence View
⚡ tsecurity.de Intelligence

Ansible Installation and Configuration on Ubuntu — Automate Your Server Management

Introduction What is Ansible? Ansible is an automation language that can describe any IT environment, whether homelab or large-scale infrastructure. It is easy…

Beitrag
0
Seite
0
↗ Quelle (dev.to)
Social ReaktionenReagiere als Erste:r — dein Feedback zählt!








Introduction






What is Ansible?



Ansible is an automation language that can describe any IT environment, whether homelab or large-scale infrastructure. It is easy to learn and reads like clear documentation.



If you manage multiple servers and find yourself doing the same configuration over and over — setting up SSH keys, disabling root users, configuring firewalls — Ansible can automate the entire process and dramatically increase your productivity.



It only requires Ansible on the Control Node and Python 3 on the Managed Node.






What is the Control Node?



The system that Ansible is installed on — it controls the remote machines.






What is the Managed Node?



The remote system or host that Ansible controls. Ansible is agentless, meaning you don't need to install Ansible on managed nodes — just Python 3.









Installing Ansible on Ubuntu (Control Node)






sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository --yes --update ppa:ansible/ansible
sudo apt install ansible







Note: Ensure Python 3 is installed on your remote server. Ubuntu 24.04 LTS ships with Python 3 by default.










Create the Inventory Folder and Hosts File



The hosts file maps the remote machines you want to control.



Folder structure:



Ansible/

├── inventory/

│ └── hosts

└── playbooks/

└── apt-update.yml



inventory/hosts




[servers]
vpsServer ansible_host=10.10.100.45
work-ToRule
10.10.45.62






You can give hosts an alias by pairing a name with an IP address. In the example above, vpsServer is an alias for 10.10.100.45.









Your First Playbook — Update Ubuntu and Set Timezone



Create playbooks/apt-update.yml:




- hosts: '*'
become: true
serial: 1
tasks:
- name: Set system timezone to Trinidad and Tobago time
community.general.timezone:
name: America/Port_of_Spain

- name: Update apt cache
apt:
update_cache: yes
cache_valid_time: 3600

- name: Upgrade all packages to the latest version
apt:
upgrade: dist

- name: Check if reboot is required
stat:
path: /var/run/reboot-required
register: reboot_required_file

- name: Reboot the server
reboot:
msg: 'Reboot initiated by Ansible due to package upgrades'
connect_timeout: 5
reboot_timeout: 300
pre_reboot_delay: 0
post_reboot_delay: 30
when: reboot_required_file.stat.exists









Breaking Down the Playbook




























Key Description
hosts: '*' Target all hosts in inventory. Use an alias, DNS name, or IP to target a single host.
become: true Grants Ansible sudo privileges.
serial: 1 Processes servers one at a time instead of all at once.
tasks A list of individual actions to run on the target hosts.


Each task has four parts:





  • name — a plain-text description of what the task does


  • Collection (community.general) — the Ansible content bundle the module belongs to


  • Module (timezone, apt, reboot) — the tool that executes the action


  • Parameters (name: America/Port_of_Spain) — the specific options passed to the module




📚 Browse all available modules and collections at docs.ansible.com










Running the Playbook






Step 1 — Test connectivity with a ping






ANSIBLE_HOST_KEY_CHECKING=FALSE ansible -i ./inventory/hosts vpsServer -m ping --user root --ask-pass



































Flag Description
ANSIBLE_HOST_KEY_CHECKING=FALSE Skips SSH host key verification — useful for fresh servers
-i ./inventory/hosts Points to your inventory file
vpsServer The target host alias
-m ping Runs the ping module to check connectivity and Python availability
--ask-pass Prompts for SSH password


Once you get a green pong response, you're ready to run the playbook.






Step 2 — Run the playbook






ansible-playbook ./playbooks/apt-update.yml --user root -e "ansible_port=22" --ask-pass --ask-become-pass -i ./inventory/hosts











































Flag Description
ansible-playbook Runs a full automation script instead of a single ad-hoc task
./playbooks/apt-update.yml Path to your playbook file
--user root SSH connection username
-e "ansible_port=22" Injects extra variable to force port 22
--ask-pass Prompts for SSH login password
--ask-become-pass Prompts for sudo password (redundant when logging in as root)
-i ./inventory/hosts Points to your inventory file





Execution Flow




  1. Ansible reads ./inventory/hosts to find the target server's IP

  2. Prompts for SSH password

  3. Prompts for sudo password

  4. Connects to port 22 as root

  5. Opens apt-update.yml and executes each task in order









Conclusion



A big shout-out to Aldo @aldo_cve for recommending Ansible in a previous post — it's been a great addition to my server management workflow.



I hope you found this walkthrough useful. Stay tuned for more posts where I share playbooks I find useful in my day-to-day infrastructure work.






Looking for developer templates built on TanStack, Directus, and Tailwind CSS? Check out my store 👇

🛒 northernrangedigital.lemonsqueezy.com

Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Ansible Installation and Configuration on Ubuntu — Automate Your Server Management

Thematisch verwandte Begriffe: Ansible, Installation, Configuration, Ubuntu · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

💬 Kommentare werden geladen…
Zum Aktualisieren ziehen
tsecurity.de Icon
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag