我有一个 ansible 库存,如下所示:
# Create an OSEv3 group that contains the masters and nodes groups
[OSEv3:children]
masters
nodes
# Set variables common for all OSEv3 hosts
[OSEv3:vars]
# SSH user, this user should allow ssh based auth without requiring a password
ansible_ssh_user=centos
# If ansible_ssh_user is not root, ansible_sudo must be set to true
ansible_sudo=true
product_type=openshift
deployment_type=enterprise
# uncomment the following to enable htpasswd authentication; defaults to DenyAllPasswordIdentityProvider
#openshift_master_identity_providers=[{'name': 'htpasswd_auth', 'login': 'true', 'challenge': 'true', 'kind': 'HTPasswdPasswordIdentityProvider', 'filename': '/etc/openshift/openshift-passwd'}]
# host group for masters
[masters]
master.example.com
# host group for nodes, includes region info
[nodes]
master.example.com openshift_node_labels="{'region': 'infra', 'zone': 'default'}"
node1.example.com openshift_node_labels="{'region': 'primary', 'zone': 'east'}"
node2.example.com openshift_node_labels="{'region': 'primary', 'zone': 'west'}"
Run Code Online (Sandbox Code Playgroud)
现在我需要密钥来使主机可供 ansible 访问。我有两把钥匙。一份用于我的主节点,另一份用于我的节点。我怎样才能改变这个脚本来告诉ansible它必须使用哪个密钥?
该脚本将在我的主人上执行。我的主人包含 2 个钥匙/root/.ssh/
目前我才private_key_file进入/etc/ansible/ansible.cfg,但只能为 Ansible 配置一个标准密钥。
您可以在清单中定义行为参数。在每个主机后面或在单独的group:vars部分中。由于您有多个共享相同密钥的节点,因此后者更有意义:
[masters:vars]
ansible_ssh_private_key_file=1.pem
[nodes:vars]
ansible_ssh_private_key_file=2.pem
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2805 次 |
| 最近记录: |