System 模块
概述
参考:
- aix_devices – Manages AIX devices
- aix_filesystem – Configure LVM and NFS file systems for AIX
- aix_inittab – Manages the inittab on AIX
- aix_lvg – Manage LVM volume groups on AIX
- aix_lvol – Configure AIX LVM logical volumes
- alternatives – Manages alternative programs for common commands
- at – Schedule the execution of a command or script file via the at command
- authorized_key – Adds or removes an SSH authorized key
- awall – Manage awall policies
- beadm – Manage ZFS boot environments on FreeBSD/Solaris/illumos systems
- capabilities – Manage Linux capabilities
- cron – Manage cron.d and crontab entries
- cronvar – Manage variables in crontabs
- crypttab – Encrypted Linux block devices
- dconf – Modify and read dconf database
- debconf – Configure a .deb package
- facter – Runs the discovery program facter on the remote system
- filesystem – Makes a filesystem
- firewalld – Manage arbitrary ports/services with firewalld
- gather_facts – Gathers facts about remote hosts
- gconftool2 – Edit GNOME Configurations
- getent – A wrapper to the unix getent utility
- group – Add or remove groups
- hostname – Manage hostname
- interfaces_file – Tweak settings in /etc/network/interfaces files
- iptables – Modify iptables rules
- java_cert – Uses keytool to import/remove key from java keystore (cacerts)
- java_keystore – Create or delete a Java keystore in JKS format
- kernel_blacklist – Blacklist kernel modules
- known_hosts – Add or remove a host from the known_hosts file
- listen_ports_facts – Gather facts on processes listening on TCP and UDP ports
- locale_gen – Creates or removes locales
- lvg – Configure LVM volume groups
- lvol – Configure LVM logical volumes
- make – Run targets in a Makefile
- mksysb – Generates AIX mksysb rootvg backups
- modprobe – Load or unload kernel modules
- mount – Control active and configured mount points
- nosh – Manage services with nosh
- ohai – Returns inventory data from Ohai
- open_iscsi – Manage iSCSI targets with Open-iSCSI
- openwrt_init – Manage services on OpenWrt
- osx_defaults – Manage macOS user defaults
- pam_limits – Modify Linux PAM limits
- pamd – Manage PAM Modules
- parted – Configure block device partitions
- pids – Retrieves process IDs list if the process is running otherwise return empty list
- ping – Try to connect to host, verify a usable python and return pong on success
- puppet – Runs puppet
- python_requirements_info – Show python path and assert dependency versions
- reboot – Reboot a machine
- runit – Manage runit services
- seboolean – Toggles SELinux booleans
- sefcontext – Manages SELinux file context mapping definitions
- selinux – Change policy and state of SELinux
- selinux_permissive – Change permissive domain in SELinux policy
- selogin – Manages linux user to SELinux user mapping
- seport – Manages SELinux network port type definitions
- service – Manage services
- service_facts – Return service state information as fact data
- setup – Gathers facts about remote hosts
- solaris_zone – Manage Solaris zones
- svc – Manage daemontools services
- sysctl – Manage entries in sysctl.conf
- syspatch – Manage OpenBSD system patches
- systemd – Manage services
- sysvinit – Manage SysV services
- timezone – Configure timezone setting
- ufw – Manage firewall with UFW
- user – Manage user accounts
- vdo – Module to control VDO
- xfconf – Edit XFCE4 Configurations
- xfs_quota – Manage quotas on XFS filesystems
setup - 收集受管理节点的信息
setup 模块在 Ansible 执行时自动运行,收集到的信息会以 Fact 变量的形式保存。
systemd - 控制远程主机上以 systemd 运行的服务
官方文档:https://docs.ansible.com/ansible/latest/collections/ansible/builtin/systemd_module.html
参数
- name(STRING) # Unit 的名称
- state(STRING) # 设置 Unit 的状态。可用的值有
- reloaded
- restarted
- started
- stopped
- enabled(BOOLEAN) # 设置 Unit 是否应该自启动
使用示例
- name: 启动并设置自启动kubelet与kube-proxy服务
systemd:
name: "{{item}}"
daemon_reload: yes
state: started
enabled: yes
with_items:
- kubelet
- kube-proxy
user - 管理远程主机上的用户账户
官方文档:https://docs.ansible.com/ansible/latest/collections/ansible/builtin/user_module.html
参数
user 模块使用示例:该示例同样适用于更改密码
- name: 创建k8s用户
user:
name: developer # 指定要创建的用户名
password: "$6$mysecretsalt$QjSLl.VQoxPKJkBE9.oLX82C5P4tAMH8UfFRpkxgkqSg2GNob8Y39hj5/cl7o0gbpPXVBGaB9oLuCPfVhIhyA0" # 使用下面Note中的命令来获取加密后的密码
- name: 同时更改多个用户的密码
user:
name: "{{ item.name }}"
password: "{{ item.chpass | password_hash('sha512') }}" # 也可以直接使用明文作为密码
update_password: always
with_items:
- { name: 'root', chpass: 'admin#123' }
- { name: 'test', chpass: 'yjun@123' }
Note:生成加密密码的方式
- ansible all -i localhost, -m debug -a “msg={{ ‘mypassword’ | password_hash(‘sha512’, ‘mysecretsalt’) }}”
- 命令中的 mypassword 就是想要使用的密码,mysecretsalt 则是密码学中加的盐,详见https://zh.wikipedia.org/wiki/%E7%9B%90_(%E5%AF%86%E7%A0%81%E5%AD%A6)
- 将输出信息引号内的部分直接当做 password 的值即可
反馈
此页是否对你有帮助?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.