うさぎ好きエンジニアの備忘録

うさぎたちに日々癒されているエンジニアが業務で直面したもの & 個人的な学習メモを残していきます。

Python3 + Ansible2.7 環境構築

最近 Python3 と Ansible2.7の検証をした際に、環境構築をしたのでそのメモ。

(Python3の環境構築については記載しません。適宜pyenvなどでインストールをお願いします。)

Python3 の準備

以前 pyenv を導入した際にインストール済みなので、適当にディレクトリを作って、local で python のバージョンを3.7.0にする。

$ mkdir ansible-python37
$ cd ansible-python37
$ pyenv versions
* system (set by /home/ponteru/.pyenv/version)
  3.7.0
$ pyenv local 3.7.9
$ pyenv versions
  system
* 3.7.0 (set by /home/ponteru/workspace/ansible-python37/.python-version)

ansible のインストール

pip3 でインストールする。

$ pip3 install ansible
$ rehash
$ ansible --version
ansible 2.7.9
  config file = None
  configured module search path = ['/home/ponteru/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/ponteru/.pyenv/versions/3.7.0/lib/python3.7/site-packages/ansible
  executable location = /home/ponteru/.pyenv/versions/3.7.0/bin/ansible
  python version = 3.7.0 (default, Mar  6 2019, 10:08:51) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]