Skip to content

Instantly share code, notes, and snippets.

@vovanmix
Last active March 17, 2016 18:43
Show Gist options
  • Save vovanmix/778b8dcd118cb1a47fa4 to your computer and use it in GitHub Desktop.
Save vovanmix/778b8dcd118cb1a47fa4 to your computer and use it in GitHub Desktop.

0-2 are necessary only if we need a user another that root to run commands for ansible

  1. Create user to run ansible.
adduser test

passwd test
  1. 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
  1. Install ansible
sudo yum install epel-release -y

sudo yum install ansible -y
  1. 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment