当前位置:网站首页>Use of ansible and common modules
Use of ansible and common modules
2022-04-23 14:22:00 【Small ash pier】
ansible
Experimental environment
Host name | IP | System |
---|---|---|
ansible_center | 192.168.75.185 | CentOS Linux release 8.1.1911 (Core) |
host_node1 | 192.168.75.186 | CentOS Linux release 8.1.1911 (Core) |
host_node2 | 192.168.75.187 | CentOS Linux release 8.1.1911 (Core) |
host_node3 | 192.168.75.188 | CentOS Linux release 8.1.1911 (Core) |
One 、ansible install
1.1 pip install
adopt pip Installed ansible The version is relative to yum Come on , I want something new
[root@centos7 ~]# yum install python-pip python-devel
[root@centos7 ~]# yum install gcc glibc-devel zibl-devel rpm-bulid openssl-devel
[root@centos7 ~]# curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py
[root@centos7 ~]# python get-pip.py
[root@centos7 ~]# pip --version
pip 20.3.4 from /usr/lib/python2.7/site-packages/pip (python 2.7)
[root@centos7 ~]# pip install ansible
[root@centos7 ~]# ansible --version
[DEPRECATION WARNING]: Ansible will require Python 3.8 or newer on the controller starting with Ansible 2.12. Current version: 2.7.5 (default, Nov 16 2020,
22:23:17) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]. This feature will be removed from ansible-core in version 2.12. Deprecation warnings can be disabled by
setting deprecation_warnings=False in ansible.cfg.
/usr/lib/python2.7/site-packages/ansible/parsing/vault/__init__.py:44: CryptographyDeprecationWarning: Python 2 is no longer supported by the Python core team. Support for it is now deprecated in cryptography, and will be removed in the next release.
from cryptography.exceptions import InvalidSignature
ansible [core 2.11.1]
config file = None
configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/site-packages/ansible
ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/bin/ansible
python version = 2.7.5 (default, Nov 16 2020, 22:23:17) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]
jinja version = 2.11.3
libyaml = True
1.2 yum install
stay ansible_center On the operation (yum install )
[root@ansible_center ~]# yum install ansible
[root@ansible_center ~]# ansible --version
ansible 2.9.21
config file = /etc/ansible/ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3.6/site-packages/ansible
executable location = /usr/bin/ansible
python version = 3.6.8 (default, Nov 21 2019, 19:31:34) [GCC 8.3.1 20190507 (Red Hat 8.3.1-4)]
Two ansible Configuration file details
[root@ansible_center ~]# rpm -ql ansible |head -15
/etc/ansible
/etc/ansible/ansible.cfg # Master profile
/etc/ansible/hosts # Host list
/etc/ansible/roles # The directory where the characters are stored
/usr/bin/ansible
/usr/bin/ansible-config
/usr/bin/ansible-connection
/usr/bin/ansible-console
/usr/bin/ansible-doc
/usr/bin/ansible-galaxy
/usr/bin/ansible-inventory
/usr/bin/ansible-playbook
/usr/bin/ansible-pull
/usr/bin/ansible-vault
/usr/lib/python3.6/site-packages/ansible
......
Master profile /etc/ansible/ansible.cfg Detailed explanation
[defaults]
#inventory = /etc/ansible/hosts # Host list profile
#library = /usr/share/my_modules/ # Library file storage directory
#remote_tmp = $HOME/.ansible/tmp # temporary py The command file is stored in the remote host directory
#local_tmp = $HOME/.ansible/tmp # Local temporary command execution Directory
#forks = 5 # Default concurrency
#sudo_user = root # Default sudo user
#ask_sudo_pass = True # Every time you execute ansible Does the command ask ssh password
#ask_pass = True
#remote_port = 22
#host_key_checking = False # Check the corresponding server's host_key, It is suggested that the annotation be cancelled
#log_path=/var/log/ansible.log # Log files , It is recommended to enable
#module_name = command # Default module , It can be changed to shell modular
default inventory file by /etc/ansible/hosts
inventory file There can be multiple , And it can also be done through Dynamic Inventory To generate dynamically
[root@ansible_center ~]# grep "^##" /etc/ansible/hosts
## green.example.com
## blue.example.com
## 192.168.100.1
## 192.168.100.10
## [webservers]
## alpha.example.org
## beta.example.org
## 192.168.1.100
## 192.168.1.110
## www[001:006].example.com
## [dbservers]
##
## db01.intranet.mydomain.net
## db02.intranet.mydomain.net
## 10.25.1.56
## 10.25.1.57
## db-[99:101]-node.example.com
ansiable Related tools
# ansible The main program , Temporary command execution tool
# ansible-doc View the configuration documentation , Module function view tool
# ansible-galaxy download / Upload excellent code or Roles The official website platform of the module
# ansible-playbook Custom automated tasks , Script tools
# ansible-pull A tool for remotely executing commands
# ansible-vault File encryption tools
# ansible-console be based on Console Tools that interact with the user interface
utilize ansible Main ways to realize management :
Ad-Hoc It is using ansible command , It is mainly used in temporary command usage scenarios
Ansible-playbook Mainly for long-term planning , Large project scenarios , There needs to be an early planning process
2.1 ansible To configure
This tool passes ssh agreement , Realize the configuration management of remote host 、 Application deployment 、 Task execution and other functions
Suggest : Before using this tool , First configure ansible The master can contact each managed node based on key authentication
# cat ssh_key1.sh
#!/bin/bash
PASS="linux_123"
NET=192.168.75
rpm -q expect &> /dev/null || yum -y install expect &> /dev/null
ssh-keygen -t rsa -P "" -f /root/.ssh/id_rsa &> /dev/null && echo "ssh key is created"
for IP in {
186..188};do
expect <<EOF set timeout 20 spawn ssh-copy-id -i /root/.ssh/id_rsa.pub root@$NET.$IP expect { "yes/no" { send "yes\n";exp_continue } "password" { send "$PASS\n" } } expect eof EOF
echo $IP is ready
done
Format :
# ansible <host-pattern> [-m module_name] [-a args]
Options :
--version # Display version
-m module # Specify modules , The default is command
-v # Detailed process –vv -vvv A more detailed
--list-hosts # Display the list of hosts , It can be abbreviated --list
-k, --ask-pass # prompt ssh Connect the password , Default Key verification
-C, --check # Check , Not implemented
-T, --timeout=TIMEOUT # The timeout for executing a command , Default 10s
-u, --user=REMOTE_USER # Users performing remote execution
-b, --become # Instead of the old version of sudo Switch
--become-user=USERNAME # Appoint sudo Of runas user , The default is root
-K, --ask-become-pass # prompt sudo Password at the time
host-pattern
List of hosts used to match controlled
All : Express all Inventory All hosts in
Example :
[root@ansible_center ~]# ansible-inventory --list
{
"_meta": {
"hostvars": {
}
},
"all": {
"children": [
"dbservers",
"ungrouped",
"webservers"
]
},
"dbservers": {
"hosts": [
"192.168.75.187",
"192.168.75.188"
]
},
"webservers": {
"hosts": [
"192.168.75.186"
]
}
}
Example :
ansible all –m ping
*: wildcard
ansible “*” -m ping
ansible 192.168.1.* -m ping
ansible “srvs” -m ping
Or relationship :
ansible “websrvs:appsrvs” -m ping
ansible “192.168.1.10:192.168.1.20” -m ping
Logic and
# stay websrvs Group and in dbsrvs Hosts in the group
ansible “websrvs:&dbsrvs” –m ping
Logic is not
# stay websrvs Group , But not here. dbsrvs Hosts in the group
# Be careful : Single quotation mark here
ansible ‘websrvs:!dbsrvs’ –m ping
Synthetic logic
ansible ‘websrvs:dbsrvs:&appsrvs:!ftpsrvs’ –m ping
Regular expressions
ansible “websrvs:dbsrvs” –m ping
ansible “~(web|db).*\.magedu\.com” –m ping
ansible Command execution process
1、 Load your own profile Default /etc/ansible/ansible.cfg
2、 Load the corresponding module file , Such as :command
3、 adopt ansible Generate the module or command corresponding to the temporary py file , And transfer the file to the corresponding user of the remote server $HOME/.ansible/tmp/ansible-tmp- Numbers /XXX.PY file
4、 Give the papers +x perform
5、 Execute and return results
6、 Delete temporary py file , sign out
3、 ... and ansible Common modules
https://docs.ansible.com/ansible/latest/modules/modules_by_category.html
3.1 command modular
function : Execute command on remote host , This is the default module , Negligible -m Options
Be careful : This command does not support $VARNAME < > | ; & etc. , use shell Module implementation
Example :
[root@ansible_center ~]# ansible dbservers -m command -a 'chdir=/etc cat centos-release'
192.168.75.188 | CHANGED | rc=0 >>
CentOS Linux release 8.1.1911 (Core)
192.168.75.187 | CHANGED | rc=0 >>
CentOS Linux release 8.1.1911 (Core)
[root@ansible_center ~]# ansible all -m command -a 'hostname'
192.168.75.187 | CHANGED | rc=0 >>
host_node2
192.168.75.188 | CHANGED | rc=0 >>
host_node3
192.168.75.186 | CHANGED | rc=0 >>
host_node1
3.2 shell modular
function : and command be similar , use shell Carry out orders
Example :
[root@ansible_center ~]# ansible dbservers -m shell -a "echo $HOSTNAME"
192.168.75.187 | CHANGED | rc=0 >>
ansible_center
192.168.75.188 | CHANGED | rc=0 >>
ansible_center
[root@ansible_center ~]# ansible dbservers -m shell -a 'echo $HOSTNAME'
192.168.75.188 | CHANGED | rc=0 >>
host_node3
192.168.75.187 | CHANGED | rc=0 >>
host_node2
[root@ansible_center ~]#
Be careful : call bash Carry out orders similar cat /tmp/test.md | awk -F‘|’ ‘{print 2}’ &> /tmp/example.txt These complex
Miscellaneous command , Even using shell It may fail , terms of settlement : When writing scripts ,copy To remote , perform , And then put the desired results
Pull back the machine that executes the command
How to modify the default module instead of command
# hold command It is amended as follows shell that will do
[root@ansible_center ~]# grep -n '^#module_name' /etc/ansible/ansible.cfg
114:#module_name = command
3.3 script modular
function : Running on a remote host ansible Scripts on the server
Example :
ansible websrvs -m script -a /data/test.sh
3.4 copy modular
function : from ansible The master server copies files to the remote host
# If the target exists , Default override , Backup first is specified here
[root@ansible_center ~]# ansible dbservers -m copy -a "src=/root/test.sh dest=/tmp/test1.sh mode=600 backup=yes"
192.168.75.188 | CHANGED => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/libexec/platform-python"
},
"changed": true,
"checksum": "5387fb90b0500b6671858d1d6eddb61f7743a91e",
"dest": "/tmp/test1.sh",
"gid": 0,
"group": "root",
"md5sum": "8733baf69fd1d36449790f6dd410d486",
"mode": "0600",
"owner": "root",
"size": 189,
"src": "/root/.ansible/tmp/ansible-tmp-1624092791.491265-2524-170538428062380/source",
"state": "file",
"uid": 0
}
192.168.75.187 | CHANGED => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/libexec/platform-python"
},
"changed": true,
"checksum": "5387fb90b0500b6671858d1d6eddb61f7743a91e",
"dest": "/tmp/test1.sh",
"gid": 0,
"group": "root",
"md5sum": "8733baf69fd1d36449790f6dd410d486",
"mode": "0600",
"owner": "root",
"size": 189,
"src": "/root/.ansible/tmp/ansible-tmp-1624092791.4955103-2522-209554212434124/source",
"state": "file",
"uid": 0
}
[root@ansible_center ~]# ansible dbservers -a 'ls -l /tmp/test1.sh'
192.168.75.188 | CHANGED | rc=0 >>
-rw------- 1 root root 189 Jun 19 16:53 /tmp/test1.sh
192.168.75.187 | CHANGED | rc=0 >>
-rw------- 1 root root 189 Jun 19 16:53 /tmp/test1.sh
# Specify content , Directly generate the target file
[root@ansible_center ~]# ansible dbservers -m copy -a "content='test line1\ntest line2' dest=/tmp/test.txt"
192.168.75.187 | CHANGED => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/libexec/platform-python"
},
"changed": true,
"checksum": "43791ccbbcf72774b2bbbe6fe8d7ab488359b922",
"dest": "/tmp/test.txt",
"gid": 0,
"group": "root",
"md5sum": "f0e596e1a1a3ef7d278f2dda4d4e6ec8",
"mode": "0644",
"owner": "root",
"size": 21,
"src": "/root/.ansible/tmp/ansible-tmp-1624093082.1497128-2627-271928500573999/source",
"state": "file",
"uid": 0
}
192.168.75.188 | CHANGED => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/libexec/platform-python"
},
"changed": true,
"checksum": "43791ccbbcf72774b2bbbe6fe8d7ab488359b922",
"dest": "/tmp/test.txt",
"gid": 0,
"group": "root",
"md5sum": "f0e596e1a1a3ef7d278f2dda4d4e6ec8",
"mode": "0644",
"owner": "root",
"size": 21,
"src": "/root/.ansible/tmp/ansible-tmp-1624093082.183581-2629-19983508277514/source",
"state": "file",
"uid": 0
}
[root@ansible_center ~]# ansible dbservers -a 'cat /tmp/test.txt'
192.168.75.188 | CHANGED | rc=0 >>
test line1
test line2
192.168.75.187 | CHANGED | rc=0 >>
test line1
test line2
# Copy /etc/ The files under the , barring /etc/ The catalog itself
[root@ansible_center ~]# ansible dbservers -m copy -a “src=/etc/ dest=/backup”
3.5 fetch modular
function : Extract files from remote host to ansible The main control terminal of ,copy contrary , Directory is not currently supported
[root@ansible_center ~]# ansible dbservers -m fetch -a 'src=/etc/redhat-release dest=/data/os'
[root@ansible_center ~]# tree /data/os/
/data/os/
├── 192.168.75.187
│ └── etc
│ └── redhat-release
└── 192.168.75.188
└── etc
└── redhat-release
4 directories, 2 files
3.6 file modular
function : Set file properties
Example :
# create a file
ansible all -m file -a 'path=/data/test.txt state=touch'
# Delete file
ansible all -m file -a 'path=/data/test.txt state=absent'
[root@ansible_center ~]# ansible dbservers -m file -a 'path=/data/test.txt owner=song mode=777 state=touch'
[root@ansible_center ~]# ansible dbservers -m shell -a 'ls -l /data/test.txt'
192.168.75.188 | CHANGED | rc=0 >>
-rwxrwxrwx 1 song root 0 Jun 19 17:26 /data/test.txt
192.168.75.187 | CHANGED | rc=0 >>
-rwxrwxrwx 1 song root 0 Jun 19 17:26 /data/test.txt
# Create directory
[root@ansible_center ~]# ansible dbservers -m file -a "path=/data/mysql state=directory owner=song group=song"
[root@ansible_center ~]# ansible dbservers -m shell -a 'ls -ld /data/mysql'
192.168.75.188 | CHANGED | rc=0 >>
drwxr-xr-x 2 song song 6 Jun 19 17:33 /data/mysql
192.168.75.187 | CHANGED | rc=0 >>
drwxr-xr-x 2 song song 6 Jun 19 17:33 /data/mysql
# Create soft link
[root@ansible_center ~]# ansible dbservers -m file -a 'src=/data/mysql dest=/data/mysql-link state=link'
[root@ansible_center ~]# ansible dbservers -m shell -a 'ls -l /data/'
192.168.75.188 | CHANGED | rc=0 >>
total 0
drwxr-xr-x 2 song song 6 Jun 19 17:33 mysql
lrwxrwxrwx 1 root root 11 Jun 19 17:36 mysql-link -> /data/mysql
-rwxrwxrwx 1 song root 0 Jun 19 17:26 test.txt
192.168.75.187 | CHANGED | rc=0 >>
total 0
drwxr-xr-x 2 song song 6 Jun 19 17:33 mysql
lrwxrwxrwx 1 root root 11 Jun 19 17:36 mysql-link -> /data/mysql
-rwxrwxrwx 1 song root 0 Jun 19 17:26 test.txt
3.7 unarchive modular
function : Unpack and decompress
There are two ways to implement :
1、 take ansible After the compressed package on the host is sent to the remote host, it is decompressed to a specific directory , Set up copy=yes
2、 Decompress a compressed package on the remote host to the specified path , Set up copy=no
Common parameters :
copy: The default is yes, When copy=yes, The copied file is from ansible Host copy to remote host , If set to copy=no, Will look for... On the remote host src Source file
remote_src: and copy The functions are the same and mutually exclusive ,yes On the remote host , be not in ansible host ,no Indicates that the document is in ansible On a host
src: The source path , It can be ansible The path on the host , It can also be a path on a remote host , If it's a path on a remote host , You need to set copy=no
dest: The destination path on the remote host
mode: Set the permissions of the extracted file
Example :
# from ansible Copy the compressed package from the host to the remote host and unzip it
[root@ansible_center ~]# ansible all -m unarchive -a 'src=/root/test.tar.gz dest=/data/'
# Copy the compressed package from the remote host and unzip it to the target point of the remote host
[root@ansible_center ~]# ansible all -m unarchive -a 'src=/root/test.tar.gz dest=/tmp/ copy=no'
3.8 archive modular
function : Packaging compression
among format These include the following :bz2, gz, tar, xz, zip
Example :
[root@ansible_center ~]# ansible all -m archive -a 'path=/var/log/ dest=/data/os-log.tar.gz format=gz owner=song mode=0600'
3.9 hostname modular
function : Manage host names
Example :
[root@ansible_center ~]# ansible webservers -m hostname -a 'name=nginx.swyer.local'
3.10 cron Templates
function : Planning tasks
Support time : branch (minute) when (hour) Japan (day) month (month) Zhou (weekday)
Example :
[root@centos8 ~]#cat mysql_backup.sh
mysqldump -A -F --single-transaction --master-data=2 -q -uroot |gzip > /data/mysql_`date +%F_%T`.sql.gz
# Create tasks
ansible 10.0.0.8 -m cron -a 'hour=2 minute=30 weekday=1-5 name="backup mysql" job=/root/mysql_backup.sh'
ansible websrvs -m cron -a "minute=*/5 job='/usr/sbin/ntpdate 172.20.0.1 &>/dev/null' name=Synctime"
# Disable scheduled tasks
ansible websrvs -m cron -a "minute=*/5 job='/usr/sbin/ntpdate 172.20.0.1 &>/dev/null' name=Synctime disabled=yes"
# Enable scheduled tasks
ansible websrvs -m cron -a "minute=*/5 job='/usr/sbin/ntpdate 172.20.0.1 &>/dev/null' name=Synctime disabled=no"
# Delete task
ansible websrvs -m cron -a "name='backup mysql' state=absent"
ansible websrvs -m cron -a 'state=absent name=Synctime'
3.11 yum modular
function : Management package , Only support RHEL,CentOS,fedora, I won't support it ubuntu Other versions
Example :
# install
[root@ansible_center ~]# ansible webservers -m yum -a 'name=vsftpd state=present'
# Delete
[root@ansible_center ~]# ansible webservers -m yum -a 'name=vsftpd state=absent'
3.12 service modular
function : management service
Example
[root@ansible_center ~]# ansible webservers -m yum -a 'name=httpd state=present'
[root@ansible_center ~]# ansible webservers -m service -a 'name=httpd state=started enabled=yes'
[root@ansible_center ~]# ansible webservers -m service -a 'name=httpd state=stopped'
[root@ansible_center ~]# ansible webservers -m service -a 'name=httpd state=reloaded’
[root@ansible_center ~]# ansible webservers -m shell -a "sed -i 's/^Listen 80/Listen 8080/' /etc/httpd/conf/httpd.conf"
[root@ansible_center ~]# ansible webservers -m service -a 'name=httpd state=restarted'
[root@ansible_center ~]# ansible webservers -m shell -a 'ss -ntl|grep 8080'
192.168.75.186 | CHANGED | rc=0 >>
LISTEN 0 128 *:8080 *:*
3.13 user modular
function : Manage users
Example
# Create user
# ansible all -m user -a 'name=user1 comment=“test user” uid=2048 home=/app/user1
group=root' # ansible all -m user -a 'name=nginx comment=nginx uid=88 group=nginx
groups="root,daemon" shell=/sbin/nologin system=yes create_home=no home=/data/nginx non_unique=yes' # Delete data such as user and home directory # ansible all -m user -a 'name=nginx state=absent remove=yes'
3.14 group modular
function : Management Group
Example
# Create group
[root@ansible_center ~]# ansible webservers -m group -a 'name=nginx gid=88 system=yes'
192.168.75.186 | CHANGED => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/libexec/platform-python"
},
"changed": true,
"gid": 88,
"name": "nginx",
"state": "present",
"system": true
}
[root@ansible_center ~]# ansible webservers -m shell -a 'getent group |grep nginx'
192.168.75.186 | CHANGED | rc=0 >>
nginx:x:88:
# Delete the group
[root@ansible_center ~]# ansible webservers -m group -a 'name=nginx state=absent'
3.15 lineinfile modular
ansible In the use of sed When replacing , We often encounter the problem of escape , and ansible When a special symbol is encountered to replace ,
Existing problems , Unable to replace properly . Actually in ansible It provides two modules :lineinfifile Module and replace modular , can
For easy replacement
function : amount to sed, You can modify the contents of the document
Example :
[root@ansible_center ~]# ansible all -m lineinfile -a "path=/etc/selinux/config regexp='^SELINUX=' line='SELINUX=enforcing'"
[root@ansible_center ~]# ansible all -m shell -a "grep '^SELINUX=' /etc/selinux/config"
192.168.75.186 | CHANGED | rc=0 >>
SELINUX=enforcing
192.168.75.187 | CHANGED | rc=0 >>
SELINUX=enforcing
192.168.75.188 | CHANGED | rc=0 >>
SELINUX=enforcing
[root@ansible_center ~]# ansible all -m lineinfile -a "dest=/etc/fstab state=absent regexp='^#'"
[root@ansible_center ~]# ansible 192.168.75.186 -m shell -a "cat /etc/fstab"
192.168.75.186 | CHANGED | rc=0 >>
UUID=e34719ca-ec48-4795-b0b0-a8145ae9b5cb / xfs defaults 0 0
UUID=5b713de2-b746-4036-a1ce-24e148c165b6 /boot ext4 defaults 1 2
UUID=7ff39b9b-efb1-44b8-9291-1b23e4551a0f /data xfs defaults 0 0
UUID=f1240d0a-0db4-4ac4-b9b8-acc4f41fc9f1 swap swap defaults 0
3.16 replace modular
The module is a bit like sed command , It is mainly based on regular matching and replacement
Example :
ansible all -m replace -a "path=/etc/fstab regexp='^(UUID.*)' replace='#\1'"
ansible all -m replace -a "path=/etc/fstab regexp='^#(.*)' replace='\1'"
3.17 setup modular
function :setup Module to collect the system information of the host , these facts Information can be used directly in the form of variables , But if there are more hosts , It affects execution speed
filter Parameters : Used for conditional filtering . If you set , Returns only information that matches the filter criteria .
ansible_all_ipv4_addresses: Show only ipv4 Information about .
ansible_devices: Display only disk device information .
ansible_distribution: It shows what the system is , example :centos,suse etc. .
ansible_distribution_major_version: The display is the main version of the system .
ansible_distribution_version: Show only system version .
ansible_machine: Display system type , example :32 position , still 64 position .
ansible_eth0: Show only eth0 Information about .
ansible_hostname: Display only the host name .
ansible_kernel: Show only kernel version .
ansible_lvm: Show lvm Related information .
ansible_memtotal_mb: Display the total memory of the system .
ansible_memfree_mb: Display available system memory .
ansible_memory_mb: Display the memory in detail .
ansible_swaptotal_mb: Show the total swap Memory .
ansible_swapfree_mb: Show swap Memory available memory .
ansible_mounts: Display the system disk mount .
ansible_processor: Show cpu Number ( Show each one specifically cpu Model ).
ansible_processor_vcpus: Show cpu Number ( Only the total number is shown )
ansible all -m setup
ansible all -m setup -a "filter=ansible_nodename"
ansible all -m setup -a "filter=ansible_hostname"
ansible all -m setup -a "filter=ansible_domain"
ansible all -m setup -a "filter=ansible_memtotal_mb"
ansible all -m setup -a "filter=ansible_memory_mb"
ansible all -m setup -a "filter=ansible_memfree_mb"
ansible all -m setup -a "filter=ansible_os_family"
ansible all -m setup -a "filter=ansible_distribution_major_version"
ansible all -m setup -a "filter=ansible_distribution_version"
ansible all -m setup -a "filter=ansible_processor_vcpus"
ansible all -m setup -a "filter=ansible_all_ipv4_addresses"
ansible all -m setup -a "filter=ansible_architecture"
ansible all -m setup -a "filter=ansible_processor*"
版权声明
本文为[Small ash pier]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231409158814.html
边栏推荐
猜你喜欢
uni-app消息推送
C语言知识点精细详解——初识C语言【1】——你不能不知的VS2022调试技巧及代码实操【1】
API gateway / API gateway (IV) - use of Kong - Integrated JWT and fuse plug-in
About the configuration and use of json5 in nodejs
查找水仙花数-for循环实践
微信小程序将原生请求通过es6的promise来进行优化
setcontext getcontext makecontext swapcontext
Thread group ThreadGroup uses introduction + custom thread factory class to implement threadfactory interface
線程組ThreadGroup使用介紹+自定義線程工廠類實現ThreadFactory接口
处理 mkdir:无法创建目录“aaa“:只读文件系统
随机推荐
C语言p2选择分支语句详解
线程组ThreadGroup使用介绍+自定义线程工厂类实现ThreadFactory接口
C语言知识点精细详解——初识C语言【1】——你不能不知的VS2022调试技巧及代码实操【1】
線程組ThreadGroup使用介紹+自定義線程工廠類實現ThreadFactory接口
爬虫练习题(一)
xx项目架构随记
STD:: map and STD:: vector memory free
C语言知识点精细详解——初识C语言【1】——你不能不知的VS2022调试技巧及代码实操【2】
source insight via samba
ActiveMQ Basics
std::map 和 std::vector 内存释放
Nacos uses demo as configuration center (IV)
微信小程序客服接入,实现发送和接收消息
Nacos作为配置中心(四) 使用Demo
On the problem of cliff growth of loss function in the process of training
redis 模块编程中 key value的生命周期
初识STL
循环队列的基本操作,你学会了吗?
Qt界面优化:Qt去边框与窗体圆角化
js 格式化时间