New FAMILUG

The PyMiers

Sunday 21 June 2015

[SaltStack] Chào Muối, em là ai?

Title phụ: How to fall in love with SaltStack?

Update: tham gia hội người dùng Salt tại Việt Nam https://www.meetup.com/VietNam-SaltStack-Meetup/

Muối, một cô gái 25 tuổi, sống nội tâm, một mình ở nơi toàn sắp thép, luôn được bao quanh bởi những anh chàng IT khô cằn mà mỗi thằng đều dấu dưới chân mình một cái giếng ngập tràn chất lỏng (nước?).
Muối không hoàn hảo, như tất cả mọi thứ trên hành tinh này.
Muối không dễ được yêu, bởi Muối chỉ dành cho những ai cần đến cô.
Nhưng Muối đơn giản (YAML), muối nhẹ nhàng (lightweight ~ 50MB RAM), dù nhiều khi hơi phũ phàng trước thay đổi (upgrade PITA).
Muối chẳng cần phải so sánh mình với ai, bởi đấy không phải cách một kẻ yêu bản thân mình sẽ sống.

Muối là tên gọi hư cấu mà tác giả dành cho SaltStack, một điều đặc biệt đã thay đổi cuộc đời anh, mãi mãi.

1. SaltStack là gì?
SaltStack (từ đây gọi tắt là Salt) là một phần mềm mã nguồn mở, một hệ thống thuộc nhóm Configuration management, viết bằng Python, sử dụng YAML làm ngôn ngữ giao tiếp với người dùng.

2. SaltStack làm gì?
- tính năng của Salt chia làm 2 phần chính: remote executionconfiguration management dựa trên nền tảng remote execution.
- Remote execution: chạy lệnh từ xa. Tức sau khi cài đặt xong salt-master (daemon đóng vai trò server) và các salt-minion (các daemon đóng vai tròn client), từ salt-master có thể chạy bất kì câu lệnh nào trên máy cài salt-minion.
Tưởng tượng bạn cần xoá 1 key SSH trên 10 hay 100 máy, chỉ cần gõ 1 câu lệnh và tất cả các minion sẽ chạy câu lệnh ấy. Sức mạnh là vô cùng khủng khiếp, giống như nắm một mạng botnet trong tay vậy. Muốn ping 1 server từ 100 máy? gõ lệnh ``ping -c N victim``, và 100 máy sẽ cùng lúc ping đến máy đích.
Configuration management: đảm bảo trạng thái các thành phần của hệ thống. Cần đảm bảo 1 service NGINX chạy với file cấu hình nhất định, forward request đến uWSGI hay unicorn app server trên máy ấy, đã cấu hình để chạy một web application viết bằng Python với phiên bản mới nhất lấy từ 1 git repository? Salt làm được tất cả điều đó, và nó có thể đảm bảo rằng mọi thay đổi bằng tay thực hiện trên những thành phần nói trên sẽ bị thay thế bằng những gì đã định trước.

3. SaltStack dành cho ai?
Đối tượng chính là các *NIX Sysadmin (Windows cũng dùng được) hay các devops, ngoài ra những ai yêu thích việc tự động hoá cũng có thể sử dụng Salt, không ít người dùng Salt để quản lý chính chiếc máy làm việc của mình.

- Remote execution: cho những người cần chạy 1 câu lệnh trên nhiều máy cùng một lúc (VD: quản lý cluster)
- Configuration management: document hệ thống, đảm bảo thống nhất cấu hình, tự động việc deploy.
Khi một hệ thống được quản lý hoàn toàn bằng một bộ "Formula", mọi bước cài đặt, cấu hình đều được ghi lại thành các state ở dạng YAML, không có bước nào có thể bị giấu đi làm bí mật riêng, toàn bộ hệ thống đều được document. Khi cần triển khai một hệ thống tương tự, chỉ cần nhập các tham số cần thiết và chạy bộ formula, một hệ thống mới tinh sẽ được thiết lập trong giây lát (vài phút :)) ).

Công việc của mỗi sysadmin hàng ngày là cài đặt phần mềm, cấu hình cho phù hợp với mục đích, vận hành, troubleshooting khi có lỗi, monitor xem có chạy ổn định không, backup ...
SaltStack là công cụ để tự động bước cài đặt, cấu hình và backup, là công cụ hỗ trợ vận hành và troubleshooting, cũng có thể dùng để monitor.

4. Yêu cầu kiến thức
- biết đọc tài liệu Tiếng Anh
- có khả năng học sử dụng YAML - thuộc loại dễ hơn cả HTML (sẽ dần dần được hướng dẫn theo tutorial của Salt)
- biết mình muốn làm gì với Salt (nấu ăn?)
- KHÔNG CẦN biết lập trình Python.

5. Cài đặt
- Salt có thể chạy một mình, không cần phải có 2 máy mới chạy được.
Mỗi salt-minion có thể tự vận hành, không cần đến salt-master. Nên để cho đơn giản, cho đến khi đã cảm thấy thoải mái với các tính năng của Salt thì không cần thiết biết đến salt-master.
- Trên Ubuntu, cài bản mới nhất (hiện tại là 2015.5) từ PPA:
sudo add-apt-repository ppa:saltstack/salt
xem hướng dẫn chi tiết ở đây (http://docs.saltstack.com/en/latest/topics/installation/ubuntu.html)
Các OS khác xem ở http://docs.saltstack.com/en/latest/topics/installation/index.html

6. Bắt đầu
Làm theo hướng dẫn của phần master-less http://docs.saltstack.com/en/latest/topics/tutorials/quickstart.html
Học viết salt states/formulas theo hướng dẫn http://docs.saltstack.com/en/latest/topics/tutorials/index.html#states
Trong quá trình này sẽ được sử dụng 2 thành phần quan trọng để làm Salt trở nên linh hoạt là salt grains và salt pillar.

Tham khảo các formula có sẵn: https://github.com/saltstack-formulas

7. Gì nữa?
- Nếu gặp khó khăn, có thể vác đi hỏi: http://docs.saltstack.com/en/latest/topics/index.html#salt-community
- Xem đầy đủ các tính năng của Salt ở : http://docs.saltstack.com/en/latest/

(còn tiếp...)
hvn@familug.org

31 comments:

  1. The market review segment of the report grandstands the market's elements and patterns, for example, the drivers, limitations, and openings that impact the ebb and flow nature and future status of this market. ai courses

    ReplyDelete
  2. This article we hope, has been able to provide some clarity on data science and its training. artificial intelligence certification

    ReplyDelete
  3. Mindblowing blog appreciating your endless efforts in developing a truly transparent content. Which probably the best one to come across disclosing the content which people might not aware of it. Thanks for bringing out the amazing content and keep sharing more further.

    360DigiTMG PMP Certification Course

    ReplyDelete
  4. Buy tiktok likes from this site https://soclikes.com/buy-tiktok-likes if you want to post video on tiktok

    ReplyDelete
  5. A debt of gratitude is in order for the blog entry amigo! Keep them coming...
    Best Digital Marketing Courses in Hyderabad

    ReplyDelete
  6. Your content is very unique and understandable useful for the readers keep update more article like this.
    data science courses

    ReplyDelete
  7. This is an excellent post I saw thanks for sharing it. It is really what I wanted to see. I hope in the future you will continue to share such an excellent post.

    best data science institute in hyderabad

    ReplyDelete
  8. A good blog always comes-up with new and exciting information and while reading I have feel that this blog is really have all those quality that qualify a blog to be a one.
    data scientist training in malaysia

    ReplyDelete
  9. This post is very simple to read and appreciate without leaving any details out. Great work!
    ai training in aurangabad

    ReplyDelete
  10. Great tips and very easy to understand. This will definitely be very useful for me when I get a chance to start my blog.
    data science training in malaysia

    ReplyDelete
  11. I have bookmarked your site since this site contains significant data in it. You rock for keeping incredible stuff. I am a lot of appreciative of this site.

    ReplyDelete
  12. 360DigiTMG, the top-rated organisation among the most prestigious industries around the world, is an educational destination for those looking to pursue their dreams around the globe. The company is changing careers of many people through constant improvement, 360DigiTMG provides an outstanding learning experience and distinguishes itself from the pack. 360DigiTMG is a prominent global presence by offering world-class training. Its main office is in India and subsidiaries across Malaysia, USA, East Asia, Australia, Uk, Netherlands, and the Middle East.

    ReplyDelete
  13. Excellent effort to make this blog more wonderful and attractive.
    data analytics courses aurangabad

    ReplyDelete
  14. Thank you so much for your great information visit naturesbox.in also

    ReplyDelete
  15. Thank You Mr Blogger . For this informative blog . If you want to know more about the Azerbaijan visa you can visit our Azerbaijan e visa website . And read here all the important info about the Azerbaijan visa or evisa.

    ReplyDelete
  16. Your article is easy to read and understand. I would like to read more articles like this. Getting a Turkey e visa online is a hassle free process. It saves time and money as well.

    ReplyDelete
  17. There are many types of information technology like PCs, sensors, robots and choice emotionally supportive networks. managed it services newcastle

    ReplyDelete
  18. This comment has been removed by the author.

    ReplyDelete
  19. Thank you so much for bringing this blog to my attention. It was simple to grasp. Individuals will benefit greatly from it. This is a fantastic blog.

    digital marketing agency in Hyderabad, India

    ReplyDelete
  20. The following are three of the most well-known content creation botches individuals make.
    ChatGPT Prompts

    ReplyDelete
  21. Your blog always impresses me! The seamless integration of profound insights and eloquent storytelling takes readers on a carefully crafted journey through a world of knowledge, tailored for individuals from all walks of life. Your ability to simplify complex ideas is truly admirable. Moreover, I aim to offer insights into the notable 2023’s Airbnb Hotspots: Spain,France, and Italy. Delve into the alluring Airbnb destinations of the upcoming year, revealing scenic lodgings, cultural treasures, and delightful experiences. Plan your next adventure confidently, discovering destinations that guarantee unforgettable moments.

    ReplyDelete
  22. Your blog stands as a treasure trove of literary brilliance. Profound insights flow seamlessly through your eloquent prose, rendering complex topics both enlightening and accessible. I wish to convey crucial information and valuable perspectives to you. Experience swifter opportunities as Canada accelerates processing for certain visas. Unlock streamlined pathways for your journey, ensuring prompt approvals and a seamless immigration process for selected visa categories.

    ReplyDelete
  23. I wanted to take a moment to let you know that your blog is like a ray of sunshine on a gloomy day. Your incredible sense of humor and cleverness truly shine through, transforming even the most ordinary subjects into a delightful experience. Your writing never fails to bring a smile to my face, and I can't thank you enough for that! Planning a trip to Turkey? Explore the essential details on visa for Turkey US citizen to ensure a smooth travel experience.

    ReplyDelete