首页 文章

ansible --limit选项继承

提问于
浏览
1

我在Ansible中应用我的剧本时遇到了问题 .

有我的库存文件/ etc / ansible / developpement:

[vm]
[...]
host1.example.com iplan=10.0.220.37
host2.example.com iplan=10.0.220.38
[...]

我想应用这样的配置:

$ ansible-playbook /etc/ansible/playbooks/developpement.yml --inventory-file=/etc/ansible/developpement --diff --check --tags php5.6-fpm --limit host1.example.com
[...]
 pm = ondemand
-pm.max_children = 599
+pm.max_children = 600
 pm.start_servers = 50
 pm.min_spare_servers = 32
 pm.max_spare_servers = 150
[...]

changed: [host1.example.net]

只更新了一个主机,这是正常行为 .

现在,我正在尝试将相同的配置应用于第二个主机:

$ ansible-playbook /etc/ansible/playbooks/developpement.yml --inventory-file=/etc/ansible/developpement --diff --check --tags php5.6-fpm --limit host2.example.com
[...]
-env[DEVELOPER] = variable linked to host 1
+env[DEVELOPER] = host2
[...]
-env[DEVELOPER_EMAIL] = email linked to host 1
+env[DEVELOPER_EMAIL] = host2@example.net
[...]



 pm.status_path = /status
 ; host-specific php ini settings here

changed: [host1.bazarchic.com]

ansible-playbook将主机1变量放入第二个请求的结果中,我不明白为什么 .

我尝试没有--check尝试,链接到host1的变量设置为第二个主机 .

我对Ansible的2.2版本没有问题 .

版本: ansible 2.6.0

Distributor ID: Ubuntu
Description:    Ubuntu 16.04.3 LTS
Release:    16.04
Codename:   xenial

文件:/etc/ansible/ansible.cfg

[defaults]
inventory      = /etc/ansible/hosts
host_key_checking = True
gather_timeout = 30
timeout = 20
log_path = /var/log/ansible.log
system_warnings = True
 deprecation_warnings = True
retry_files_enabled = False
[privilege_escalation]
[paramiko_connection]
[ssh_connection]
ssh_args = -o ControlMaster=auto -o ControlPersist=60s -o ForwardAgent=yes -o ConnectTimeout=30 -o StrictHostKeyChecking=no -o ControlPath=/dev/shm/cp%%h-%%p-%%r
[accelerate]
[selinux]
[colors]

1 回答

  • 1

    我发现了这个问题 .

    在ansible.cfg中,这是我的SSH选项连接:

    ssh_args = -o ControlMaster=auto -o ControlPersist=60s -o ForwardAgent=yes -o ConnectTimeout=30 -o StrictHostKeyChecking=no -o ControlPath=/dev/shm/cp%%h-%%p-%%r
    

    我删除了“ControlPath”选项,它可以工作 .

    在我看来,这个选项对于ansible 2.3来说毫无用处

相关问题