Ansible is a powerful configuration management tool that we use in managing our infrastructure and applications.
It requires a centralized Control
server and can connect to hosts over an array of connection types including SSH.
The Ansible controller will run our playbooks. This needs both Ansible and Semaphore (web based management console) setup.
Ansible is the main dependency. This will run our configuration management.
sudo apt-get -y install software-properties-common
sudo apt-get -y install python-software-properties
sudo apt-add-repository -y ppa:ansible/ansible
sudo apt-get -y update
sudo apt-get -y install ansible
sudo apt-get -y install python-passlib
The configuration file can be found in /etc/ansible/ansible.cfg
.
We need to disable host_key_checking
else our plays will hang asking us to add the host certificate.
Search for and uncomment the relevant line.
host_key_checking: False
Semaphore is an open sourced alternative to Ansible Tower.
It is a web based GUI that helps us run our playbooks and manage our tasks properly.
To install semaphore, you need MySQL running on the server.
sudo apt-get -y update
sudo apt-get -y install mysql-server
Follow the prompts to complete the setup including entering the password.
Secure the installation. You will be prompted for the root password when you run this command.
sudo mysql_secure_installation
Disable all remote connections and delete all defaults when prompeted.
- Enable validate password plugin:
[y]
onSTRONG [2]
setting. - Remove anonymous users:
[y]
- Disallow root login remotely:
[y]
. - Remove test database and access to it:
[y]
. - Reload privilege tables:
[y]
If MySQL 5.7 is used, the initialize step is not necessary and will raise an error which you can ignore.
sudo mysqld --initialize
Check if mysql is running
service mysql status
If it isn't, start the service
sudo service mysql start
Test your credentials to the database
mysqladmin -p -u root version
Get <link> for recent release for OS version here.
Ubuntu uses semaphore_linux_amd64
Run the installation.
sudo apt-get install -y wget git
wget <link>
sudo mv semaphore_linux_amd64 /usr/bin/semaphore
chmod +x /usr/bin/semaphore
sudo mkdir -p /opt/data/semaphore
sudo chown $(whoami): /opt/data/semaphore
Initialize semaphore for the first time
semaphore -setup
You will be required to enter the following configs
- DB Hostname:
default [enter]
- DB User:
default [enter]
- DB Password:
[password specified earlier] [enter]
- DB Name:
default [enter]
- Playbook path:
/opt/data/semaphore
- Accept configuration:
[y]
- Username:
[admin] [enter]
- Email:
[[email protected]] [enter]
- Username:
[admin] [enter]
- Name:
[admin] [enter]
- Password:
[admin] [enter]
Run using
semaphore -config /opt/data/semaphore/semaphore_config.json
or as a daemon:
nohup semaphore -config /opt/data/semaphore/semaphore_config.json &
Point your browser to port 3000 and start managing.
when i execute "semaphore -setup" i get a syntax error, what can i do?
/usr/bin/semaphore: línea 1: syntax error near unexpected element
newline' /usr/bin/semaphore: línea 1:
!'