Centos/rehl 6 Installation Configuration Ansible

Source: Internet
Author: User

Install: Dependent packages: A jinja2:python of the designer-friendly modern template language Pyyaml:python a YAML encoding/deserialization function library Paramiko: SSHv2 written in pure Python Protocol function Library HTTPLIB2: A full-featured HTTP client function library   installation Ansible[[email protected] ~]# yum list|grep -i  ansibleFailed to set locale, defaulting to Cansible.noarch                              1.9.2-1.el6                    epelansible-inventory-grapher.noarch          & nbsp 1.0.1-2.el6                    epelansible-lint.noarch    &NBS P                    2.0.1-1.el6                    epel[[email protected] ~]# yum install ansible.noarch  ansible-inventory-grapher.noarch ansible-lint.noarch -y Simple configuration: # Vim/etc/ansible/ansible.cfgremote_port = 22private_key_file =/root/.ssh/id_rsa # defines a group[[email  protected] ~]# tail -n 3 /etc/ansible/hosts [myservers]192.168.4.98192.168.2.98  usage;1. Execute Simple Command[[email protected] ~]# ansible myservers -m command -a   ' Uptime ' 192.168.4.98 | success | rc=0 >> 08:23:14 up 61  days,  8:02,  0 users,  load average: 0.00, 0.00, 0.00  192.168.2.98 | success | rc=0 >> 08:23:14 up 61 days,  10:01,  0 users,  load average: 0.00, 0.00, 0.00 2. Cope file from the local to remote server. [[email protected] ~]# ansible myservers -m copy -a  "src=/root/test.sh  dest=/tmp/test.sh owner=root group=root mode=0755 "192.168.2.98&Nbsp;| success >> {    "changed": true,    "checksum":  " d51e9d0762e103dced4b6bc84e6af6d48ab44762 ",   " dest ": "/tmp/test.sh ",   " gid ":  0,     "group":  "root",    "md5sum":  "69eaa9aae1337871c084de2e62b45109",    " Mode ": " 0755 ",   " owner ": " root ",   " size ": 20,   " src ": "/root /.ansible/tmp/ansible-tmp-1437380034.46-279493020985021/source ",   " state ": " file ",   " UID ": 0} 192.168.4.98 | success >> {   " changed ":  true,     "checksum":  "d51e9d0762e103dced4b6bc84e6af6d48ab44762",    "dest":  "/tmp/test.sh ",    GID": 0,    "group":  "root",    "md5sum":  " 69eaa9aae1337871c084de2e62b45109 ",   " mode ": " 0755 ",   " owner ": " Root ",    "Size": 20,   " src ": "/root/.ansible/tmp/ansible-tmp-1437380034.47-136677121174897/source ",     "state":  "file",    "UID":  0} 3. Execute script on remote server. [[email protected] ~]# ansible myservers -m shell -a  "sh /tmp/ Test.sh "192.168.4.98 | success | rc=0 >> 08:14:28 up 61  days,  7:53,  0 users,  load average: 0.00, 0.00, 0.00 192.168.2.98  | success | rc=0 >> 08:14:27 up 61 days,  9:52,  0  users,  load average: 0.00, 0.00, 0.00 4. Install Software with Yum[[email protected] ~]# ansible myservers -m yum -a   ' name=httpd state=latest ' 192.168.4.98 | success >> {    "changed" : false,     "msg":  "", &NBsp;    "RC": 0,     "results": [        "all packages  providing httpd are up to date "   ]} 192.168.2.98 |  success >> {    "changed": false,     "msg":  ",     "RC": 0,     "results": [        "all packages  Providing httpd are up to date "   ]} 5. Manage service[[email protected] ~]# ansible myservers -m service -a  ' Name=httpd state=started ' 192.168.4.98 | success >> {    "changed":  false,     "name":  "httpd",     "state":  "started"}  192.168.2.98 | success >> {    "changed": false,     "name ": " httpd ",    " state": " Started "} 

Centos/rehl 6 Installation configuration ansible

Related Article

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.