0-2 are necessary only if we need a user another that root to run commands for ansible
- Create user to run ansible.
adduser test
passwd test
- make it possible to run commands as root without a password
sudo visudo
## Allow root to run any commands anywhere
<ansible user> ALL=(ALL) NOPASSWD: ALL
esc, :wq!
su test
ssh-keygen
ssh-copy-id localhost
- Install ansible
sudo yum install epel-release -y
sudo yum install ansible -y
- make it possible to connect to the app server without a password. (control server only) Run it on the
control
server:
su test
ssh-keygen
ssh-copy-id [email protected]
The last command will allow you to log to the xxx.xxx.xxx.xxx
server from the control
server without password as user
4) Config hosts (control server only)
cd /etc/ansible
mv hosts hosts.original
nano hosts
[local]
localhost
[remote]
domain1.com
#install on Debian
apt-get update
apt-get install python-pip python-dev git -y
pip install PyYAML jinja2 paramiko
git clone https://github.com/ansible/ansible.git
cd ansible
git submodule update --init --recursive
make install
mkdir /etc/ansible
cp ~/ansible/examples/hosts /etc/ansible/
#on Mac
brew install ansible
https://github.com/beautifulcode/ssh-copy-id-for-OSX
curl -L https://raw.githubusercontent.com/beautifulcode/ssh-copy-id-for-OSX/master/install.sh | sh
key exchange with the remote machine:
ssh-keygen
ssh-copy-id root@ip
All confings will be in ~/.ansible.cfg
nano ~/.ansible.cfg
add
[defaults]
hostfile=~/ansible/hosts