LoginSignup
13
12

More than 3 years have passed since last update.

Ansible: ターゲットノードでpython3を使用するansible.cfg設定は、ansible_python_interpreterでは無くinterpreter_python

Last updated at Posted at 2020-02-28

Ansibleでターゲットノードにてpython3を使用する

ansible.cfgによるpython3指定でトラブルに遭遇したので備忘

環境

ansible 2.9.4, 2.9.5

変数で設定

変数で設定する場合には、ansible_python_interpreterを使用する。

  • ansible-playbookコマンドに対する-eオプションによる設定例
$ ansible-playbook -e ansible_python_interpreter=/usr/bin/python3 site.yml
  • inventoryにおける設定例
inventory
[all:vars]
ansible_python_interpreter=/usr/bin/python3
  • play vars, task varsなどにおける設定例
playなど
vars:
  ansible_python_interpreter: /usr/bin/python3

公式: Python 3 Support > Using Python 3 on the managed machines with commands and playbooks

ansible.cfgによる設定

ansible.cfgにおいて設定する場合、ansible_python_interpreterでは無く、interpreter_pythonを使用する事に注意。

ansible.cfg
[defaults]
interpreter_python=/usr/bin/python3

公式: Ansible Configuration Settings > interpreter-python

13
12
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
12