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)
We have confirmed the operation below. RHEL 7.1 Ansible 2.9
- name: Modify hostname
hostname:
name: johnn
There are some restrictions on the operation, but you can do something like the systemd command. In the use case, httpd is restarted.
- name: Restart httpd
systemd:
name: httpd
state: restarted
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
- name: Modify root password
user:
name: root
password: "{{Enter your password here| password_hash('sha512') }}"
It's a module named file, but you can also create directories. It can also be deleted.
- name: create directory
file:
path: /johnn
state: directory
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.
- name: Set locale LANG
command: localectl set-locale LANG=en_US.UTF-8
- name: Set timezone
timezone:
name: Asia/Tokyo
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.
- name: copy file
copy:
src:Copy source path
dest:Copy destination path
owner: root
group: root
mode: "0644"
I put the message settings, but they were not displayed.
- name: Reboot test
reboot:
msg: "Rebooting."
If you feel like it, I'll post about adding more discs as well.
Recommended Posts