I tried to summarize Ansible modules-Linux edition

I think there is SE, but I will check the same thing many times, so I think I will make it index-like all together. (I will also summarize the ones that I do not use many times)

environment

We have confirmed the operation below. RHEL 7.1 Ansible 2.9

Linux related

Host name change

hostname

Example of use

- name: Modify hostname
  hostname:
    name: johnn

service management

There are some restrictions on the operation, but you can do something like the systemd command. In the use case, httpd is restarted.

systemd

Example of use

- name: Restart httpd
  systemd:
    name: httpd
    state: restarted

Change user information

In the example below, it is used to change the password, but it seems that the user's startup shell etc. can also be changed. For details, refer to the link below

user

Example of use

- name: Modify root password
  user:
    name: root
    password: "{{Enter your password here| password_hash('sha512') }}"

Object creation

It's a module named file, but you can also create directories. It can also be deleted.

file

Example of use

- name: create directory
  file:
    path: /johnn
    state: directory

Command execution

Basically, it is best to use Ansible modules, but there are some that are not available, so For such items, this module is used to execute commands.

There are some differences between command and shell, so I think you should use it according to your requirements.

command shell

Example of use

- name: Set locale LANG
  command: localectl set-locale LANG=en_US.UTF-8

Time zone setting

timezone

Example of use

- name: Set timezone
  timezone:
    name: Asia/Tokyo

Copy file

It can be used to copy files. If there is a difference between the copy destination path and the copy source file, it will be copied.

copy

Example of use

- name: copy file
  copy:
    src:Copy source path
    dest:Copy destination path
    owner: root
    group: root
    mode: "0644"

Reboot

I put the message settings, but they were not displayed.

reboot

Example of use

- name: Reboot test
  reboot:
    msg: "Rebooting."

If you feel like it, I'll post about adding more discs as well.

Recommended Posts

I tried to summarize Ansible modules-Linux edition
I tried to summarize SparseMatrix
I tried to summarize Python exception handling
Python3 standard input I tried to summarize
I tried to summarize the graphical modeling.
I tried to debug.
I tried to paste
I tried adding post-increment to CPython Extra edition
LeetCode I tried to summarize the simple ones
I tried to learn PredNet
I tried to summarize how to use matplotlib of python
I tried to summarize the basic form of GPLVM
I tried to organize SVM.
I tried to implement PCANet
I tried to summarize four neural network optimization methods
I tried to reintroduce Linux
I tried to introduce Pylint
I tried to summarize how to use pandas in python
I tried to touch jupyter
I tried to summarize the string operations of Python
I tried to extract characters from subtitles (OpenCV: tesseract-ocr edition)
[First COTOHA API] I tried to summarize the old story
I tried to summarize the code often used in Pandas
I tried to summarize the commands often used in business
[Machine learning] I tried to summarize the theory of Adaboost
I tried to summarize SQLAlchemy briefly (There is also TIPS)
I tried to implement SSD with PyTorch now (model edition)
I tried to summarize how to use the EPEL repository again
I tried to implement Deep VQE
I tried to create Quip API
I tried to touch Python (installation)
I tried to implement adversarial validation
I tried to explain Pytorch dataset
I tried Watson Speech to Text
I tried to touch Tesla's API
I tried to implement hierarchical clustering
I tried to organize about MCMC.
I tried to estimate the interval.
I tried to solve the ant book beginner's edition with python
[Linux] I tried to summarize the command of resource confirmation system
I tried to summarize what was output with Qiita with Word cloud
I tried to summarize the commands used by beginner engineers today
I tried to summarize everyone's remarks on slack with wordcloud (Python)
I tried to summarize the frequently used implementation method of pytest-mock
I tried to create a linebot (implementation)
I tried to implement PLSA in Python
I tried using Azure Speech to Text.
I tried to create a linebot (preparation)
I tried to visualize AutoEncoder with TensorFlow
I tried to recognize the wake word
I tried to get started with Hy
I tried to implement PLSA in Python 2
I tried to classify text using TensorFlow
I tried adding post-increment to CPython Implementation
I tried to implement ADALINE in Python
I tried to let optuna solve Sudoku
I tried to estimate the pi stochastically
I tried to implement PPO in Python
I tried to implement CVAE with PyTorch
I tried to make a Web API
I tried to solve TSP with QAOA