Professional Documents
Culture Documents
Pass For Hack
Pass For Hack
To configure the PPA on your machine and install ansible run these commands:
```
$ sudo apt-get update
$ sudo apt-get install software-properties-common
$ sudo apt-add-repository ppa:ansible/ansible
$ sudo apt-get update
$ sudo apt-get install ansible
```
```
$ ansible --version
```
**Notes**
*Repositories* are a more trustworthy way to download software than grabbing files
from random websites. Since everything in the default repositories is reviewed by
the Ubuntu team before it goes out, you know everything there is completely safe
for your system. A downside is that users typically have to wait for a new version
of Ubuntu to try out new software.
The *apt-get* utility is a powerful and free package management command line
program, that is used to work with Ubuntu's *APT* (*Advanced Packaging Tool*)
library to perform installation of new software packages, removing existing
software packages, upgrading of existing software packages and even used to
upgrading the entire operating system.
*apt-get update* downloads the package lists from the repositories and "updates"
them to get information on the newest versions of packages and their dependencies.
It will do this for all repositories and PPAs.
## SSH
To test if there is any existing key open a terminal and run the following. If you
see "No such file or directory", then there aren't any.
```
$ cd ~/.ssh
```
If you don't have an existing SSH key that you wish to use, generate one. Open a
terminal on your local computer and enter the following:
```
$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
```
Associating the key with your email address helps you to identify the key later on.
Just press <Enter> to accept the default location and file name. If the .ssh
directory doesn't exist, the system creates one for you. Enter, and re-enter, a
passphrase when prompted.
## Ansible
Since ansible uses ssh to access to each of the remote hosts, before we execute a
playbook, we need to put the public key to the `~/.ssh/authorized_keys` so that you
don't need to input the password for ssh every time you execute the playbook.
Usually, people just manually copy the public key to the remote hosts'
`~/.ssh/authorized_keys` files. But things could get quite exhausting when you have
an inventory with more than hundreds of nodes. That's why people are asking how to
use ansible playbook to deploy the public key to the remote hosts.
(This hasn't been tested yet.)
**Working solution**
Open the config file:
```
$ vim /etc/ansible/ansible.cfg
```
```
[defaults]
host_key_checking = False
```
```
$ vim /etc/ansible/hosts
```
And add these two lines at the end.
```
[test]
192.168.1.50 ansible_python_interpreter=/usr/bin/python3
```
If necessary, change the IP address and the name of the group. If Python 2 is
installed on the server machine, there is no need to add Python 3 path to the file.
```
$ ansible test -m ping -u studiopresent --ask-pass -vvv
```
And type in password when asked for. Extra -vvv parameter will just print
additional information, which is not necessary if there is no error.