Skip to content
Snippets Groups Projects
Commit c5704fb6 authored by Moises Sacal's avatar Moises Sacal
Browse files

Add README.md

parents
Branches
No related merge requests found
## Ansible Notes
### Bootstraping Ansible
To run ansible you need a couple of things.
Control Node: Any machine with Ansible installed. You can run commands and playbooks
Managed Node: Any machine with Ansible installed. You can run commands and playbooks
Step 1. Managed Node: Modify visudo
Ansible needs to run commands as sudo without password
`sudo visudo`
Find and uncomment
This line
`%wheel ALL=(ALL) NOPASSWD: ALL`
to:
`wheel ALL=(ALL) NOPASSWD: ALL`
Step 2. Control Node: ansible.cfg
```
[defaults]
inventory = ./hosts.live
remote_user = <THE USERNAME THAT IS GOING TO RUN Ansible Scripts>
```
Step 2. Managed Node: (SKIP if you already have one) Create an ssh key
Add user ansible
```
sudo useradd ansible -m
#add to wheel
sudo usermod -aG wheel ansible
```
Create Key (this will create a key with no passphrase
```bash
ssh-keygen -t rsa -C "ansible@myremotemachine" -f "$(pwd)/keys/myremotemachine.id_rsa" -P ""
```
Add it to authorized_keys
sudo mkdir /home/ansible/.ssh/
sudo touch /home/ansible/.ssh/authorized_keys
sudo chmod 700 /home/ansible/.ssh
sudo chmod 700 /home/ansible/.ssh/authorized_keys
sudo chown -R ansible:ansible /home/ansible
sudo cat $(pwd)/keys/HOSTNAME.id_rsa.pub >> /home/ansible/.ssh/authorized_keys
Step 3. Control Node: Add this key to host.live (Defined in ansible.cfg)
```
[myremotemachine]
123.x.x.x
[myremotemachine:vars]
`ansible_ssh_private_key_file=keys/myremotemachine.id_rsa`
```
Step 4. Managed Node: Install Ansible
```
wget --output-document /tmp/get-pip.py https://bootstrap.pypa.io/get-pip.py
sudo python /tmp/get-pip.py
sudo pip install ansible
```
Step 4. Control Node: Verify this by running ansible all -m ping
$ `ansible all -m ping`
```bash
myremotemachine | SUCCESS => {
"changed": false,
"ping": "pong"
}
```
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment