Ansible--General account to do batch deployment

Source: Internet
Author: User

Used to play ansible, the root account is used to manage. Now to the production environment, can not be so casual, I believe that many other companies are also banned from the root SSH connection.

Therefore, I have a problem with this deployment, many articles on the internet, are not elaborate on this piece. I also groping to do out, through this practice, but also further deepened the understanding of ansible. Hope can help the vast number of friends.

The deployment steps are as follows

1.1 Checking the Ansible.cfg configuration file on the management machine

# vi/etc/ansible/ansible.cfg

Sudo_user = root/* Make sure the configuration is like this */

1.2 The default ansible is verified with key

If you use a password to log on to the server, use Ansible,

Do not modify the Ansible.cfg configuration file to ask_pass= true to uncomment,

Or just add-K when you run the command, which means-K,--ask-pass ask for SSH password

1.3 If the client is not in the know_hosts will be an error

If you want to resolve this issue, you need to modify Ansible.cfg's #host_key_checking = False Uncomment

1.4 Create a regular account on the management machine and add sudo

# Useradd CPIs

# passwd CPIs

# vi/etc/sudoers

CPIs all= (All) Nopasswd:all

1.5 Create a regular account on the managed machine and add sudo

# Useradd CPIs

# passwd CPIs

# vi/etc/sudoers

CPIs all= (All) Nopasswd:all

1.6 The key is generated on the management machine and copied to the managed machine

# Su-cpis

[[email protected] ~]$ ssh-keygen-t RSA

[Email protected] ~]$ ssh-copyid-i 172.31.28.61

1.7 Management machine to do the test

# ansible 172.31.28.61-u CPIs--sudo-a ' Ls/root '

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/58/D5/wKioL1S-FA6S2OWtAAEYQD2IEuI685.jpg "title=" 3.png " alt= "Wkiol1s-fa6s2owtaaeyqd2ieui685.jpg"/>

This means that the test passes, and it achieves our original purpose.


This article from "Hanyun.fang" blog, reproduced please contact the author!

Ansible--General account to do batch deployment

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.