how to specify user name in host file of ansible

后端 未结 2 1634
青春惊慌失措
青春惊慌失措 2021-02-19 09:08

I am using the host file as below,

[qa-workstations]
10.39.19.190 ansible_user=test ansible_ssh_pass=test

I am using below command to execute \

相关标签:
2条回答
  • 2021-02-19 09:40

    Create an ansible.cfg in your playbook directory or modify the "global" ansible.cfg

    Note: Only 1 configuration file is processed. First one wins in the below list. http://docs.ansible.com/ansible/intro_configuration.html

    • ANSIBLE_CONFIG (an environment variable)
    • ansible.cfg (in the current directory)
    • .ansible.cfg (in the home directory)
    • /etc/ansible/ansible.cfg
    [defaults]
    remote_user=test
    
    0 讨论(0)
  • 2021-02-19 09:40

    With recent versions of Ansible, you can use the ansible_user parameter in the host definition.

    For example, on the host mysql-host.mydomain the user I need to connect with is mysql :

    [docker-hosts]
    mysql-host.mydomain ansible_user=mysql
    

    But as you are using an older version of ansible, you might need to use ansible_ssh_user instead

    http://docs.ansible.com/ansible/faq.html#how-do-i-handle-different-machines-needing-different-user-accounts-or-ports-to-log-in-with

    0 讨论(0)
提交回复
热议问题