how to define ssh private key for servers fetched by dynamic inventory in files

前端 未结 5 1180
小蘑菇
小蘑菇 2020-12-12 15:32

I met one configuration problem when coding ansible playbook for ssh private key file.

As we know, we can define combination with host server, ip & related ssh p

5条回答
  •  余生分开走
    2020-12-12 16:18

    You can simply define the key to use directly when running the command:

    ansible-playbook \
            \ # Super verbose output incl. SSH-Details:
        -vvvv \
            \ # The Server to target: (Keep the trailing comma!)
        -i "000.000.0.000," \
            \ # Define the key to use:
        --private-key=~/.ssh/id_rsa_ansible \
            \ # The `env` var is needed if `python` is not available:
        -e 'ansible_python_interpreter=/usr/bin/python3' \ # Needed if `python` is not available
            \ # Dry–Run:
        --check \
        deploy.yml
    

    Copy/ Paste:

    ansible-playbook -vvvv --private-key=/Users/you/.ssh/your_key deploy.yml
    

提交回复
热议问题