Common Ansible Commands

Source: Internet
Author: User
Tags file copy openssl
Common ansible Commands

Use Ansible-doc-l to see how specific modules are used, here are examples of common ansible simple usage Execution system commands

[Root@ansible ~]# ansible pinpoint-m shell-a ' hostname '-o  # Execute system command
192.168.0.102 | SUCCESS | rc=0 | (stdout) pinpoint-agent
192.168.0.101 | SUCCESS | rc=0 | (stdout) Apm-pinpoint
File copy
[Root@ansible ~]# echo "Itdevops is useful" > devops.txt [root@ansible ~]# ansible pinpoint-m copy-a ' Src=devops.txt Dest=/root/devops.txt owner=root group=root mode=644 backup=yes '-O 192.168.0.102 | SUCCESS = {"Changed": True, "checksum": "59e127fdd346abcd4a2e348e44691600018d95d5", "dest": "/root/devops.txt", " GID ": 0," group ":" Root "," md5sum ":" 9ada44440028d3aa4582f7d5cfcbfe99 "," mode ":" 0644 "," owner ":" Root "," size ": +," src " : "/root/.ansible/tmp/ansible-tmp-1489047961.58-135666976081973/source", "state": "File", "UID": 0} 192.168.0.101 | SUCCESS = {"Changed": True, "checksum": "59e127fdd346abcd4a2e348e44691600018d95d5", "dest": "/root/devops.txt", " GID ": 0," group ":" Root "," md5sum ":" 9ada44440028d3aa4582f7d5cfcbfe99 "," mode ":" 0644 "," owner ":" Root "," size ": +," src " : "/root/.ansible/tmp/ansible-tmp-1489047961.6-141588290458447/source", "state": "File", "UID": 0} [Root@ansible ~]# Ansible pinpoint-m shell-a ' cat/root/devops.txt '-O 192.168.0.102 | SUCCESS | Rc=0 | (stdout) Itdevops is useful 192.168.0.101 | SUCCESS | rc=0 | (stdout) Itdevops is useful
Package Management
[Root@ansible ~]# ansible pinpoint-m yum-a ' Name=lrzsz state=latest '-o     # Install package
192.168.0.101 | SUCCESS = {"Changed": false, "MSG": "", "RC": 0, "Results": ["all packages providing Lrzsz is up to date", "" "]}
1 92.168.0.102 | SUCCESS = {"Changed": false, "MSG": "", "RC": 0, "Results": ["all packages providing Lrzsz is up to date", "" "}

[ Root@ansible ~]# ansible pinpoint-m yum-a "Name=lrzsz state=present"  # yum install lrzsz-y
[root@ansible ~]# an Sible pinpoint-m yum-a "Name=lrzsz state=absent"   # Yum Erase lrzsz-y
User Management
[Root@ansible ~]# echo ansible | OpenSSL passwd-1-stdin   # using OpenSSL to generate home encrypted passwords
$1$7nqb45m/$QhN 9dim77y5a.cryrhp.g/
[root@ansible ~]# ansible Pinpoint-m user-a ' Name=shaon password= "$1$7nqb45m/$QhN 9dim77y5a.cryrhp.g/" '-O

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.