Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the Ansible modules?

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the relevant knowledge of "what are the Ansible modules?". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Authorized_key

SSH is the core of Ansible, at least for almost all other functions except Windows. The key to efficient use of SSH in Ansible (no pun) is... The key! By the way, you can do a lot of cool things for security with SSH keys. It is worth reading the "authorized_keys" section of the sshd man page carefully. If you need fine-grained user access control, managing SSH keys can be laborious, and although I can use either of the next two my favorite modules, I prefer to use authorized_key because it can be easily managed through variables.

File

In addition to the obvious ability to place files somewhere, the file module can also set ownership and permissions. What I want to say is that such a module can bring a lot of benefits. A large part of the security issues are also related to setting permissions, so the file module and authorized_key work well together.

Template

There are so many ways to manipulate the contents of a file that I see a lot of people using lineinfile. I've used it for small tasks myself. However, the template module is much clearer because you maintain the context of the entire file. I prefer to write Ansible content in a way that anyone can easily understand-for me, that means it's easy to understand what's going on. The use of template means that you can see the entire file in which you are placing content, all the variables you are changing.

Uri

Many modules in the current release use Ansible as an orchestration tool. Instead of doing specific things, such as putting a file in one place, they talk to another service. Usually, this kind of conversation is also conducted through HTTP. Before many of these modules appeared, you could program API directly using the uri module. It is a powerful access tool that enables you to do a lot of things. In my Ansible virtual shed, I won't lose it.

Shell

This is the trump card in our toolkit, the Swiss Army knife. If you are very upset about how to control other things, don't say, it's shell. Some people would say that we make Ansible a Bash script-but what I want to say is that it has some advantages, because you can use the name parameter to record every step in your script and character. To me, it's like a big reward. Back when I was still consulting, I helped a database administrator (DBA) migrate to Ansible. The DBA doesn't like change and is a hindrance to changing the way he works. So, in order to simplify the migration to Ansible, we used the shell module in Ansible to invoke some existing database management scripts. And a detailed name statement was attached to the mission.

You can achieve a lot of things through these five modules. Yes, modules designed to accomplish specific tasks will make your life easier. However, with simple engineering design, you can almost get twice the result with half the effort.

This is the end of the content of "what are the Ansible modules"? thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report