Giter Club home page Giter Club logo

ghichep-ansible's Introduction

ghichep-ansible

Ghi chép về ansible

Mục lục

Lịch sử ghi chép

  • 14/03/2015: Tạo tài liệu | congto

Ghi chép

Vai trò - Chức năng

  • Dùng để configuration management
  • Là provisioning tool

Cách cài đặt

  • Mô hình
                        |------Client1(Ubuntu 12.04)
                        |
Server(Ubuntu 14.04)----|------Client2(Ubuntu 14.04)
                        |
                        |------Client3(CentOS 6.5)
  • Môi trường
Trên server: 
Ubuntu 14.04-2 64bit

Phía Client 
Ubuntu 12.04
Ubuntu 14.04
CentOS 6.5
  • Lệnh cài đặt trên Server
sudo apt-add-repository -y ppa:ansible/ansible
sudo apt-get update
sudo apt-get install -y ansible
  • Phiên bản của Ansible hiện tại (14.03.2015)
root@u14:~# ansible --version
ansible 1.8.4
  configured module search path = None
root@u14:~#
  • Phía Client không cần cài đặt, chỉ cần cho phép truy nhập ssh bằng pass dạng text hoặc sử dụng ssh-key

Ví dụ về việc thực hiện lệnh ping tới các máy Client trên Ansible.

  • Sao lưu file /etc/ansible/hosts trước khi cấu hình
cp /etc/ansible/hosts /etc/ansible/hosts.bka
  • Tạo file /etc/ansible/hosts mới với nội dung như sau
# IP cua 03 may client

[ubuntu]
172.16.69.215
172.16.69.248

[centos]
172.16.69.243
  • Thực hiện lện dưới để kiểm tra ping tới các máy Client bằng Ansible (nhớ phải cho phép ssh bằng root tới các client)
ansible all -m  ping -k -u root
  • Giải thích tùy chọn lệnh
all : gọi tất cả các server được khai báo trong file hosts (ví dụ này là 04 server, kể cả chính máy chủ cài Ansible Server)
-m ping : sử dụng mô-đun ping trong Ansible để thực hiện lệnh ping.
-k : yêu cầu xác thực khi thực hiện các lệnh từ xa đối với Client.
-u root : đăng nhập và thực hiện lệnh `ping` ở trên bằng tài khoản `root` của Client. Mặc định sử dụng quyền `root`
  • Kết quả sẽ như sau:

ansible-ping

Ví dụ kiểm tra phiên bản của các máy Client

ansible all  -m setup -a 'filter=ansible_distribution' -k

ansible-version-os.png

Ví dụ cài Apache trên các máy là Ubuntu

# Lưu ý tùy chọn `all` thay bằng `ubuntu`, được định nghĩa trong file hosts.

ansible ubuntu -m shell -a 'sudo apt-get install apache2 -y' -k
SSH password:

Các module hay dùng

Tham khảo tài liệu

Cập nhật thêm các mục sau:

  • Các thuật ngữ trong Ansible.
  • Tổng quan , những kiến thức cần có để bắt đầu với Ansible.
  • Cập nhật về cách sử dụng về Module SQL (cụ thể là MySQL)
  • Project.

ghichep-ansible's People

Contributors

congto avatar datkk06 avatar linhlt247 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.