我定义了一个自定义ansible.cfg,并将其导出到中,如下所示
export ANSIBLE_CONFIG="../aws_ansible.cfg"
当我运行它时,它会被拾取,但当我将库存作为arg传递时,它无法识别arg或优先,尽管aws_ansible.cfg
中没有指定库存。
export ANSIBLE_CONFIG=../aws_ansible.cfg
ansible-playbook demo.yml -i ./inventories/dev1 --verbose
Using /projects/demo/aws_ansible.cfg as config file
如果我在aws_ansible.cfg
中指定库存,它会起作用,但我想将其作为参数传递。
请告知extra-vars
是否也优先于aws_ansible.cfg
中规定的内容
aws_ansible.cfg
看起来像
[defaults]
; strategy_plugins = ../mitogen/ansible_mitogen/plugins/strategy
private_key_file=~/.ssh/id_rsa
inventory = ./inventories/dev2/hosts
remote_user=ec2-user
host_key_checking = false
filter_plugins = ./filter_plugins
roles_path = ./roles
retry_files_enabled = False
[ssh_connection]
ssh_args = -o ControlMaster=auto -o ControlPersist=600s -o ControlPath="~/.ansible/cp/ansible-ssh-%h-%p-%r"
pipelining = True
您可能想了解列出了哪些ansible_inventory_sources。
- debug:
msg: "{{ ansible_inventory_sources }}"