欢迎光临散文网 会员登陆 & 注册

Ansible配置

2023-03-25 13:14 作者:每天输出五分钟  | 我要投稿


Ansible Configuration

Precedence from lowest to highest

Configuration File

Find the first ‘ansible.cfg’ in these locations in order:

Environment Variable: ANSIBLE_CONFIG

Current Directory

Home Directory ~/

/etc/ansible

Generate a sample file

ansible-config init --disabled > ansible.cfg

ansible-config init --disabled -t all > ansible.cfg

includes existing plugins

Environment Variables

Command-line options

Commands

ansible

ansible-config

ansible-console

ansible-doc

ansible-galaxy

ansible-inventory

ansible-playbook

ansible-pull

ansible-vault

Options

Help

ansible -h

ansible-playbook -h

... ...

For option that accepts only a single value, the last one wins

Eg:

ansible -m ping myhost -u mike -u carol

ansible -m ping myhost -u carol

For option that allow multiple values, append all

Eg:

ansible -i /path/inventory1 -i /path/inventory2 -m ping all

Playbook keywords

Eg, connection

Variables (Connection variables)

Set the specifics on how to execute actions on a target

ansible_become_user

ansible_connection

ansible_host

ansible_python_interpreter

ansible_user

Define

In inventory

In playbooks

Using extra variables at the command line

-e or --extra-vars

ansible -u carol -e 'ansible_user=brian' -a whoami all

brian



Ansible配置的评论 (共 条)

分享到微博请遵守国家法律