Skip to content

Ansible playbook to automate initial server setup of Ubuntu servers

Notifications You must be signed in to change notification settings

finid/ansible-ubuntu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Automate Initial Server Setup of Multiple Ubuntu 22.04 Servers Using Ansible

This playbook shows how to automates the initial server setup of Ubuntu 22.04 servers using Ansible. It implements all the steps given in the Initial Server Setup Guide for Ubuntu 20.04 tutorial, then adds a few more steps to make the servers more secure.

Variables required to execute some parts of the playbook are specified in the vars/default.yml variable file. You'll need to modify the default Ansible inventory, or hosts, file (/etc/ansible/hosts) on your local machine so that it contains the IP addresses of the target hosts.

Settings

The following variables are defined in vars/default.yml.

  • create_user: the name of the remote user to create.
  • ssh_port: the custom port for logging into the hosts after the initial server setup.
  • copy_local_key: path to a local SSH public key that will be copied as authorized key for the new user. By default, it copies the key from the home directory of the user running Ansible.

Running this Playbook

Quick Steps:

1. Obtain the playbook

git clone https://github.com/finid/ansible-ubuntu.git
cd ansible-ubuntu

2. Customize Options

nano vars/default.yml
#vars/default.yml
create_user: sammy
ssh_port: 5995
copy_local_key: "{{ lookup('file', lookup('env','HOME') + '/.ssh/id_rsa.pub') }}"

3. Use Ansible Vault To Create An Encrypted Password File

Details in the tutorial...

4. Run the Playbook

Best to perform a syntax-check of the playbook.

ansible-playbook --syntax-check initial.yml

Then run the the playbook.

ansible-playbook --ask-vault-pass initial.yml

4. Run the other playbook

As a bonus, another playbook is included that you can use to maintain the servers after the initial server setup.

ansible-playbook --syntax-check ongoing.yml

Then run the the playbook.

ansible-playbook --ask-vault-pass ongoing.yml

For more information on how to run this Ansible setup, please check this guide: Automate Initial Server Setup of Multiple Ubuntu 22.04 Servers Using Ansible.

About

Ansible playbook to automate initial server setup of Ubuntu servers

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published