Ansible notes;

Source: Internet
Author: User
Tags node server

A

1, installation Ansible

# yum Install Ansible-y

(Can update under Epel yum source/python2.6 above)

# wget http://mirrors.sohu.com/fedora-epel/6/x86_64/epel-release-6-8.noarch.rpm

# RPM-IVH pel-release-6-8.noarch.rpm

2, installation verification;

650) this.width=650; "src=" http://s1.51cto.com/wyfs02/M02/82/89/wKiom1dYA0Sze06-AAAmJfMZgx8023.jpg "style=" float: none; "title=" 0.jpg "alt=" Wkiom1dya0sze06-aaamjfmzgx8023.jpg "/>


Two

1, configure the host (password-free login)

The First Direct remote node host directly in Ansible;

The second copy of node's private key/root/.ssh/id_rsa.pub to Ansible's/root/.ssh/authorized_keys;


2. Configuration Definition Host Inventory

# cat/etc/ansible/hosts

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/82/87/wKioL1dYB92xAU3KAAAekVE__p4374.jpg "title=" 7.jpg " alt= "Wkiol1dyb92xau3kaaaekve__p4374.jpg"/>

Under the hosts are two node hosts;

Ansible_ssh_user=root is SSH login user

ansible_ssh_pass=guoting is SSH login password


Third, the test module;

1, verify node time;

650) this.width=650; "src=" http://s1.51cto.com/wyfs02/M01/82/89/wKiom1dYA0TCGtPfAAAiLE_MNwQ608.jpg "style=" float: none; "title=" 1.jpg "alt=" Wkiom1dya0tcgtpfaaaile_mnwq608.jpg "/>

650) this.width=650; "src=" http://s1.51cto.com/wyfs02/M01/82/87/wKioL1dYBE6TeqgEAAAj1GQhlrA572.jpg "title=" 3.jpg " Style= "Float:none;" alt= "wkiol1dybe6teqgeaaaj1gqhlra572.jpg"/>

2, verify the basic information of the host;

650) this.width=650; "src=" http://s1.51cto.com/wyfs02/M02/82/87/wKioL1dYBE3yjxS_AAB3p3Nzpus466.jpg "style=" float: none; "title=" 2.jpg "alt=" Wkiol1dybe3yjxs_aab3p3nzpus466.jpg "/>


3, verify the view configuration file;

650) this.width=650; "src=" http://s1.51cto.com/wyfs02/M00/82/89/wKiom1dYA0Wyw9xuAAA0YHLiC90690.jpg "style=" float: none; "title=" 4.jpg "alt=" Wkiom1dya0wyw9xuaaa0yhlic90690.jpg "/>

4, copy files;

Create an SH file in ansible. Then distributed to the node server;

vi/opt/7.sh

[Email protected] ~]# cat/opt/7.sh

#!/bin/bash

Let A=1

Let b=2

echo $[$A + $B]

650) this.width=650; "src=" http://s1.51cto.com/wyfs02/M02/82/89/wKiom1dYA0WRQq1RAABTM9kaX60069.jpg "style=" float: none; "title=" 5.jpg "alt=" Wkiom1dya0wrqq1raabtm9kax60069.jpg "/>

5. Test Execution 7.sh

650) this.width=650; "src=" http://s1.51cto.com/wyfs02/M00/82/87/wKioL1dYBE7whqASAAAbm5jDvdQ809.jpg "style=" float: none; "title=" 6.jpg "alt=" Wkiol1dybe7whqasaaabm5jdvdq809.jpg "/>


+

+

+

(Ansible use notes to Be continued)

This article is from the "Logs" blog, make sure to keep this source http://51log.blog.51cto.com/6076767/1787541

Ansible notes;

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.