ansibleのクライアント側への設定

#### 目的
ansibleの実行先ホストはssh接続出来れば良いと勘違いしていた。
実際動かしてたら上手くいかず調べて見たらpythonが入っていないといけない。
凄い恥ずかしい。今までは自身に対して打ってたからansible入れた段階でpython2.7に切り替わってやっていたんだろうと思われる。
今回はクライアント側の設定を行う。(といっても単にパッケージを入れるだけです。)

#### 前提条件
- 実行先を用意する。今回はubuntu16.04.1を使用
- インターネット接続が出来ること(パッケージインストール出来れば無しで良い)

#### pythonのバージョンについて
ubuntu16.04を使用している場合、デフォルトではpython3が入ってきており、python2.x系は入ってこない。ansibleではpython2.xを使用するとの事でpython2.x系を入れる

#### 手順

##### サーバ側手順

1. サーバ側の鍵生成
2. クライアント側へ鍵登録
3. ansibleのhostsファイル修正

```txt:実行コマンド
cd ~/.ssh;ssh-keygen
cd ~/.ssh;ssh-copy-id [クライアントのIPアドレス]
sudo vi /etc/ansible/hosts
```

```txt:実際のコマンド結果
openstack@Ubuntu16041Server:~$ cd ~;ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/openstack/.ssh/id_rsa):★何も打たずに「enter」
Enter passphrase (empty for no passphrase):★何も打たずに「enter」
Enter same passphrase again:★何も打たずに「enter」
Your identification has been saved in /home/openstack/.ssh/id_rsa.
Your public key has been saved in /home/openstack/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:wsAG6DjUhnIV9nNYK0JmoKmZoMFKYeq9sl5yopU5V9c openstack@Ubuntu16041Server
The key's randomart image is:
+---[RSA 2048]----+
| +=oB.  .        |
|*=oX . o .       |
|@+. = = o        |
|X=.. + + .       |
|*o .  + S E      |
|   o.. o         |
| +=+.            |
|..Bo             |
|oo               |
+----[SHA256]-----+
openstack@Ubuntu16041Server:~$
openstack@Ubuntu16041Server:~$ ssh-copy-id 192.168.56.101
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/openstack/.ssh/id_rsa.pub"
The authenticity of host '192.168.56.101 (192.168.56.101)' can't be established.
ECDSA key fingerprint is SHA256:0iR9bUQBi9xSFYsTvTkLDDaBdQ7jbsHwZJNhs2ZQ8KY.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
openstack@192.168.56.101's password:

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh '192.168.56.101'"
and check to make sure that only the key(s) you wanted were added.
openstack@Ubuntu16041Server:~$
openstack@Ubuntu16041Server:~$ egrep 192.168.56.101 /etc/ansible/hosts -B 10
#   - Groups of hosts are delimited by [header] elements
#   - You can enter hostnames or ip addresses
#   - A hostname/ip can be a member of multiple groups

# Ex 1: Ungrouped hosts, specify before any group headers.

## green.example.com
## blue.example.com
## 192.168.100.1
## 192.168.100.10
192.168.56.101 ★ここに追記
```

##### クライアント側手順
1. pythonの関連パッケージを導入する

```txt:実行コマンド
sudo apt-get install -y python-simplejson
```

#### おまけ
入ったパッケージ情報を抜粋

```txt:package情報(必要パッケージ入れる前)
openstack@ubuntu160401client:~$ dpkg -l | grep python
ii  dh-python                          2.20151103ubuntu1.1             all          Debian helper tools for packaging Python libraries and applications
ii  libpython3-stdlib:amd64            3.5.1-3                         amd64        interactive high-level object-oriented language (default python3 version)
ii  libpython3.5:amd64                 3.5.2-2~16.01                   amd64        Shared Python runtime library (version 3.5)
ii  libpython3.5-minimal:amd64         3.5.2-2~16.01                   amd64        Minimal subset of the Python language (version 3.5)
ii  libpython3.5-stdlib:amd64          3.5.2-2~16.01                   amd64        Interactive high-level object-oriented language (standard library, version 3.5)
ii  python-apt-common                  1.1.0~beta1build1               all          Python interface to libapt-pkg (locales)
ii  python3                            3.5.1-3                         amd64        interactive high-level object-oriented language (default python3 version)
ii  python3-apport                     2.20.1-0ubuntu2.1               all          Python 3 library for Apport crash report handling
ii  python3-apt                        1.1.0~beta1build1               amd64        Python 3 interface to libapt-pkg
ii  python3-chardet                    2.3.0-2                         all          universal character encoding detector for Python3
ii  python3-commandnotfound            0.3ubuntu16.04.2                all          Python 3 bindings for command-not-found.
ii  python3-dbus                       1.2.0-3                         amd64        simple interprocess messaging system (Python 3 interface)
ii  python3-debian                     0.1.27ubuntu2                   all          Python 3 modules to work with Debian-related data formats
ii  python3-distupgrade                1:16.04.14                      all          manage release upgrades
ii  python3-gdbm:amd64                 3.5.1-1                         amd64        GNU dbm database support for Python 3.x
ii  python3-gi                         3.20.0-0ubuntu1                 amd64        Python 3 bindings for gobject-introspection libraries
ii  python3-minimal                    3.5.1-3                         amd64        minimal subset of the Python language (default python3 version)
ii  python3-newt                       0.52.18-1ubuntu2                amd64        NEWT module for Python3
ii  python3-pkg-resources              20.7.0-1                        all          Package Discovery and Resource Access using pkg_resources
ii  python3-problem-report             2.20.1-0ubuntu2.1               all          Python 3 library to handle problem reports
ii  python3-pycurl                     7.43.0-1ubuntu1                 amd64        Python bindings to libcurl (Python 3)
ii  python3-requests                   2.9.1-3                         all          elegant and simple HTTP library for Python3, built for human beings
ii  python3-six                        1.10.0-3                        all          Python 2 and 3 compatibility library (Python 3 interface)
ii  python3-software-properties        0.96.20.2                       all          manage the repositories that you install software from
ii  python3-systemd                    231-2build1                     amd64        Python 3 bindings for systemd
ii  python3-update-manager             1:16.04.3                       all          python 3.x module for update-manager
ii  python3-urllib3                    1.13.1-2ubuntu0.16.04.1         all          HTTP library with thread-safe connection pooling for Python3
ii  python3.5                          3.5.2-2~16.01                   amd64        Interactive high-level object-oriented language (version 3.5)
ii  python3.5-minimal                  3.5.2-2~16.01                   amd64        Minimal subset of the Python language (version 3.5)
openstack@ubuntu160401client:~$
openstack@ubuntu160401client:~$ which python
openstack@ubuntu160401client:~$
openstack@ubuntu160401client:~$ which python3
/usr/bin/python3
```

```txt:package情報(必要パッケージ入れた後)
openstack@ubuntu160401client:~$ dpkg -l | grep python
ii  dh-python                          2.20151103ubuntu1.1             all          Debian helper tools for packaging Python libraries and applications
ii  libpython-stdlib:amd64             2.7.11-1                        amd64        interactive high-level object-oriented language (default python version)
ii  libpython2.7-minimal:amd64         2.7.12-1~16.04                  amd64        Minimal subset of the Python language (version 2.7)
ii  libpython2.7-stdlib:amd64          2.7.12-1~16.04                  amd64        Interactive high-level object-oriented language (standard library, version 2.7)
ii  libpython3-stdlib:amd64            3.5.1-3                         amd64        interactive high-level object-oriented language (default python3 version)
ii  libpython3.5:amd64                 3.5.2-2~16.01                   amd64        Shared Python runtime library (version 3.5)
ii  libpython3.5-minimal:amd64         3.5.2-2~16.01                   amd64        Minimal subset of the Python language (version 3.5)
ii  libpython3.5-stdlib:amd64          3.5.2-2~16.01                   amd64        Interactive high-level object-oriented language (standard library, version 3.5)
ii  python                             2.7.11-1                        amd64        interactive high-level object-oriented language (default version)
ii  python-apt-common                  1.1.0~beta1build1               all          Python interface to libapt-pkg (locales)
ii  python-minimal                     2.7.11-1                        amd64        minimal subset of the Python language (default version)
ii  python-simplejson                  3.8.1-1ubuntu2                  amd64        simple, fast, extensible JSON encoder/decoder for Python
ii  python2.7                          2.7.12-1~16.04                  amd64        Interactive high-level object-oriented language (version 2.7)
ii  python2.7-minimal                  2.7.12-1~16.04                  amd64        Minimal subset of the Python language (version 2.7)
ii  python3                            3.5.1-3                         amd64        interactive high-level object-oriented language (default python3 version)
ii  python3-apport                     2.20.1-0ubuntu2.1               all          Python 3 library for Apport crash report handling
ii  python3-apt                        1.1.0~beta1build1               amd64        Python 3 interface to libapt-pkg
ii  python3-chardet                    2.3.0-2                         all          universal character encoding detector for Python3
ii  python3-commandnotfound            0.3ubuntu16.04.2                all          Python 3 bindings for command-not-found.
ii  python3-dbus                       1.2.0-3                         amd64        simple interprocess messaging system (Python 3 interface)
ii  python3-debian                     0.1.27ubuntu2                   all          Python 3 modules to work with Debian-related data formats
ii  python3-distupgrade                1:16.04.14                      all          manage release upgrades
ii  python3-gdbm:amd64                 3.5.1-1                         amd64        GNU dbm database support for Python 3.x
ii  python3-gi                         3.20.0-0ubuntu1                 amd64        Python 3 bindings for gobject-introspection libraries
ii  python3-minimal                    3.5.1-3                         amd64        minimal subset of the Python language (default python3 version)
ii  python3-newt                       0.52.18-1ubuntu2                amd64        NEWT module for Python3
ii  python3-pkg-resources              20.7.0-1                        all          Package Discovery and Resource Access using pkg_resources
ii  python3-problem-report             2.20.1-0ubuntu2.1               all          Python 3 library to handle problem reports
ii  python3-pycurl                     7.43.0-1ubuntu1                 amd64        Python bindings to libcurl (Python 3)
ii  python3-requests                   2.9.1-3                         all          elegant and simple HTTP library for Python3, built for human beings
ii  python3-six                        1.10.0-3                        all          Python 2 and 3 compatibility library (Python 3 interface)
ii  python3-software-properties        0.96.20.2                       all          manage the repositories that you install software from
ii  python3-systemd                    231-2build1                     amd64        Python 3 bindings for systemd
ii  python3-update-manager             1:16.04.3                       all          python 3.x module for update-manager
ii  python3-urllib3                    1.13.1-2ubuntu0.16.04.1         all          HTTP library with thread-safe connection pooling for Python3
ii  python3.5                          3.5.2-2~16.01                   amd64        Interactive high-level object-oriented language (version 3.5)
ii  python3.5-minimal                  3.5.2-2~16.01                   amd64        Minimal subset of the Python language (version 3.5)
openstack@ubuntu160401client:~$
openstack@ubuntu160401client:~$ which python
/usr/bin/python
openstack@ubuntu160401client:~$ ls -lrta /usr/bin/python
lrwxrwxrwx 1 root root 9 Dec 10  2015 /usr/bin/python -> python2.7
openstack@ubuntu160401client:~$
openstack@ubuntu160401client:~$ python --version
Python 2.7.12
```