Ansible_编写循环和条件任务
一、利用循环迭代任务
1️⃣:Ansible支持使用loop关键字对一组项目迭代任务,可以配置循环以利用列表中的各个项目、列表中各个文件的内容、生成的数字序列或更为复杂的结构来重复任务
1、简单循环
1️⃣:简单循环对一组项目迭代任务。loop关键字添加到任务中,将应对其迭代任务的项目列表取为值。循环变量item保存每个迭代过程中使用的值
- 演示实例:
//查看playbook
[root@localhost project]# cat playbook.yaml
---
- hosts: all
tasks:
- name: create user
user:
name: "{{ item }}"
state: present
loop:
- zhangsan
- lisi //测试执行play
[root@localhost project]# ansible-playbook playbook.yaml -C PLAY [all] **************************************************************************************************************************************************************** TASK [Gathering Facts] ****************************************************************************************************************************************************
ok: [client.example.com] TASK [create user] ********************************************************************************************************************************************************
changed: [client.example.com] => (item=zhangsan)
changed: [client.example.com] => (item=lisi) PLAY RECAP ****************************************************************************************************************************************************************
client.example.com : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
2️⃣:此外、还可以通过变量给loop提供所使用的的列表
- 演示实例:
//查看playbook
[root@localhost project]# cat playbook.yaml
---
- hosts: all
vars:
users:
- zhangsan
- lisi
- wangwu
tasks:
- name: create user
user:
name: "{{ item }}"
state: present
loop: "{{ users }}" //执行play
[root@localhost project]# ansible-playbook playbook.yaml -C PLAY [all] **************************************************************************************************************************************************************** TASK [Gathering Facts] ****************************************************************************************************************************************************
ok: [client.example.com] TASK [create user] ********************************************************************************************************************************************************
changed: [client.example.com] => (item=zhangsan)
changed: [client.example.com] => (item=lisi)
changed: [client.example.com] => (item=wangwu) PLAY RECAP ****************************************************************************************************************************************************************
client.example.com : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
2、循环散列或字典列表
1️⃣: loop列表不需要是简单值列表
- 演示实例:item标识一个循环的项目(任务),item.name和item.group表示item的两个键值(键值可自定义,但必须与loop中的项目匹配)
//查看playbook文件
[root@localhost project]# cat playbook.yaml
---
- hosts: all
tasks:
- name: create user
user:
name: "{{ item.name }}"
group: "{{ item.group}}"
state: present
loop:
- name: zhangsan
group: zhangsan
- name: lisi
group: lisi //测试是否可play
[root@localhost project]# ansible-playbook playbook.yaml -C PLAY [all] **************************************************************************************************************************************************************** TASK [Gathering Facts] ****************************************************************************************************************************************************
ok: [client.example.com] TASK [create user] ********************************************************************************************************************************************************
changed: [client.example.com] => (item={'name': 'zhangsan', 'group': 'zhangsan'})
changed: [client.example.com] => (item={'name': 'lisi', 'group': 'lisi'}) PLAY RECAP ****************************************************************************************************************************************************************
client.example.com : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
3、将Register变量于Loop一起使用
- 演示实例:
//查看playbook
[root@localhost project]# cat playbook.yaml
---
- hosts: all
tasks:
- name: show some user
shell: 'echo this user is {{ item }}'
loop:
- zhangsan
- lisi
- wangwu
register: result - name: show these user
debug:
var: result //测试是否执行play
[root@localhost project]# ansible-playbook playbook.yaml -C PLAY [all] **************************************************************************************************************************************************************** TASK [Gathering Facts] ****************************************************************************************************************************************************
ok: [client.example.com] TASK [show some user] *****************************************************************************************************************************************************
skipping: [client.example.com] => (item=zhangsan)
skipping: [client.example.com] => (item=lisi)
skipping: [client.example.com] => (item=wangwu) TASK [show these user]
............
"item": "zhangsan",
"msg": "skipped, running in check mode",
"skipped": true
............
"item": "lisi",
"msg": "skipped, running in check mode",
"skipped": true
.............
"item": "wangwu",
"msg": "skipped, running in check mode",
"skipped": true
.............
1️⃣: 在上面的例子中,results键包含一个列表。在下面,修改了playbook,使第二个任务迭代此列表
- 演示实例:
//查看playbook
[root@localhost project]# cat playbook.yaml
---
- hosts: all
tasks:
- name: show some user
shell: 'echo this user is {{ item }}'
loop:
- zhangsan
- lisi
- wangwu
register: magic - name: show these user
debug:
msg: "{{ item.stdout }}"
loop: "{{ magic['results'] }}" //执行play
[root@localhost project]# ansible-playbook playbook.yaml PLAY [all] **************************************************************************************************************************************************************** TASK [Gathering Facts] ****************************************************************************************************************************************************
ok: [client.example.com] TASK [show some user] *****************************************************************************************************************************************************
changed: [client.example.com] => (item=zhangsan)
changed: [client.example.com] => (item=lisi)
changed: [client.example.com] => (item=wangwu) TASK [show these user] ****************************************************************************************************************************************************
ok: [client.example.com] => (item={'cmd': 'echo this user is zhangsan', 'stdout': 'this user is zhangsan', 'stderr': '', 'rc': 0, 'start': '2020-09-03 15:28:50.767109', 'end': '2020-09-03 15:28:50.774188', 'delta': '0:00:00.007079', 'changed': True, 'invocation': {'module_args': {'_raw_params': 'echo this user is zhangsan', '_uses_shell': True, 'warn': True, 'stdin_add_newline': True, 'strip_empty_ends': True, 'argv': None, 'chdir': None, 'executable': None, 'creates': None, 'removes': None, 'stdin': None}}, 'stdout_lines': ['this user is zhangsan'], 'stderr_lines': [], 'failed': False, 'item': 'zhangsan', 'ansible_loop_var': 'item'}) => {
"msg": "this user is zhangsan"
}
ok: [client.example.com] => (item={'cmd': 'echo this user is lisi', 'stdout': 'this user is lisi', 'stderr': '', 'rc': 0, 'start': '2020-09-03 15:28:51.542241', 'end': '2020-09-03 15:28:51.547953', 'delta': '0:00:00.005712', 'changed': True, 'invocation': {'module_args': {'_raw_params': 'echo this user is lisi', '_uses_shell': True, 'warn': True, 'stdin_add_newline': True, 'strip_empty_ends': True, 'argv': None, 'chdir': None, 'executable': None, 'creates': None, 'removes': None, 'stdin': None}}, 'stdout_lines': ['this user is lisi'], 'stderr_lines': [], 'failed': False, 'item': 'lisi', 'ansible_loop_var': 'item'}) => {
"msg": "this user is lisi"
}
ok: [client.example.com] => (item={'cmd': 'echo this user is wangwu', 'stdout': 'this user is wangwu', 'stderr': '', 'rc': 0, 'start': '2020-09-03 15:28:52.292883', 'end': '2020-09-03 15:28:52.298768', 'delta': '0:00:00.005885', 'changed': True, 'invocation': {'module_args': {'_raw_params': 'echo this user is wangwu', '_uses_shell': True, 'warn': True, 'stdin_add_newline': True, 'strip_empty_ends': True, 'argv': None, 'chdir': None, 'executable': None, 'creates': None, 'removes': None, 'stdin': None}}, 'stdout_lines': ['this user is wangwu'], 'stderr_lines': [], 'failed': False, 'item': 'wangwu', 'ansible_loop_var': 'item'}) => {
"msg": "this user is wangwu"
} PLAY RECAP ****************************************************************************************************************************************************************
client.example.com : ok=3 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
二、有条件的运行任务
Ansible可使用conditionals在符合特定条件时执行任务或play。例如,可以利用一个条件在Ansible安装或配置服务前确定受管主机上的可用内存
1、条件任务语法
1️⃣:when语句用于有条件地运行任务;它取要测试的条件为值。如果条件满足,则运行任务。如果条件不满足,则跳过任务
- 演示实例:
//查看playbook
[root@localhost project]# cat playbook.yaml
---
- hosts: all
vars:
package: True
tasks:
- name: install httpd
yum:
name: httpd
state: installed
when: package //测试执行play
[root@localhost project]# ansible-playbook playbook.yaml PLAY [all] **************************************************************************************************************************************************************** TASK [Gathering Facts] ****************************************************************************************************************************************************
ok: [client.example.com] TASK [install httpd] ******************************************************************************************************************************************************
changed: [client.example.com] PLAY RECAP ****************************************************************************************************************************************************************
client.example.com : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
2️⃣:处理条件时可使用的一些运算示例:
| 操作 | 示例 |
|---|---|
| 等于(值为字符串) | ansible_machine == "x86_64" |
| 等于(值为数字) | max_memory == 512 |
| 小于 | min_memory < 128 |
| 大于 | min_memory > 256 |
| 小于等于 | min_memory <= 256 |
| 大于等于 | min_memory >= 512 |
| 不等于 | min_memory != 512 |
| 变量存在 | min_memory is defined |
| 变量不存在 | min_memory is not defined |
| 布尔变量是True。1、True或yes的求值为True | memory_available |
| 布尔变量是False。0、False或no的求值为False | not memory_available |
| 第一个变量的值存在,作为第二个变量的列表中的值 | ansible_distribution in supported_distros |
- 演示实例一:
//查看playbook
[root@localhost project]# cat playbook.yaml
---
- hosts: all
vars:
package: httpd
tasks:
- name: install {{ package }}
yum:
name: "{{ package }}"
state: present
when: package is defined //执行play
[root@localhost project]# ansible-playbook playbook.yaml PLAY [all] **************************************************************************************************************************************************************** TASK [Gathering Facts] ****************************************************************************************************************************************************
ok: [client.example.com] TASK [install httpd] ******************************************************************************************************************************************************
changed: [client.example.com] PLAY RECAP ****************************************************************************************************************************************************************
client.example.com : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
- 演示实例二:第一个变量的值存在(一般是事实),且作为第二个变量列表中的值
//查看playbook
[root@localhost project]# cat playbook.yaml
---
- hosts: all
vars:
version:
- RedHat
- CentOS
tasks:
- name: install httpd
yum:
name: httpd
state: present
when: ansible_facts['distribution'] in version //ansible_facts['distribution']该变量的值与versionversion中的值匹配 //执行play
[root@localhost project]# ansible-playbook playbook.yaml PLAY [all] **************************************************************************************************************************************************************** TASK [Gathering Facts] ****************************************************************************************************************************************************
ok: [client.example.com] TASK [install httpd] ******************************************************************************************************************************************************
changed: [client.example.com] PLAY RECAP ****************************************************************************************************************************************************************
client.example.com : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
- 演示实例三:(判断大小)
//查看playbook
[root@localhost project]# cat playbook.yaml
---
- hosts: all
vars:
number: 800
tasks:
- name: install httpd
yum:
name: httpd
state: present
when: number >= 800 //执行play
[root@localhost project]# ansible-playbook playbook.yaml PLAY [all] **************************************************************************************************************************************************************** TASK [Gathering Facts] ****************************************************************************************************************************************************
ok: [client.example.com] TASK [install httpd] ******************************************************************************************************************************************************
changed: [client.example.com] PLAY RECAP ****************************************************************************************************************************************************************
client.example.com : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
2、测试多个条件
1️⃣:一个when语句可用于评估多个条件:使用and和or关键字组合条件,并使用括号分组条件
2️⃣:使用and语句运算时,两个条件必须为真,才能满足整个条件语句
- 演示实例一:and 语句第一种写法
//查看playbook
[root@localhost project]# cat playbook.yaml
---
- hosts: all
tasks:
- name: install httpd
yum:
name: httpd
state: present
when: ansible_facts['distribution_version'] == "8.1" and ansible_facts['distribution'] == "RedHat" //执行play
[root@localhost project]# ansible-playbook playbook.yaml PLAY [all] **************************************************************************************************************************************************************** TASK [Gathering Facts] ****************************************************************************************************************************************************
ok: [client.example.com] TASK [install httpd] ******************************************************************************************************************************************************
changed: [client.example.com] PLAY RECAP ****************************************************************************************************************************************************************
client.example.com : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
- 演示实例二:and 语句第二种写法
//查看playbook
[root@localhost project]# cat playbook.yaml
---
- hosts: all
tasks:
- name: install httpd
yum:
name: httpd
state: present
when:
- ansible_facts['distribution_version'] == "8.1"
- ansible_facts['distribution'] == "RedHat" //执行play
[root@localhost project]# ansible-playbook playbook.yaml PLAY [all] **************************************************************************************************************************************************************** TASK [Gathering Facts] ****************************************************************************************************************************************************
ok: [client.example.com] TASK [install httpd] ******************************************************************************************************************************************************
changed: [client.example.com] PLAY RECAP ****************************************************************************************************************************************************************
client.example.com : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
- 演示实例三:and 语句第三中写法
//查看playbook
[root@localhost project]# cat playbook.yaml
---
- hosts: all
tasks:
- name: install httpd
yum:
name: httpd
state: present
when:
( ansible_facts['distribution_version'] == "8.1" )
and
( ansible_facts['distribution'] == "RedHat" ) //执行play
[root@localhost project]# ansible-playbook playbook.yaml PLAY [all] **************************************************************************************************************************************************************** TASK [Gathering Facts] ****************************************************************************************************************************************************
ok: [client.example.com] TASK [install httpd] ******************************************************************************************************************************************************
changed: [client.example.com] PLAY RECAP ****************************************************************************************************************************************************************
client.example.com : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
3️⃣:使用or语句时,其中任一条件为真时,就能满足条件语句
- 演示实例一:or 语句第一种写法
//查看playbook
[root@localhost project]# cat playbook.yaml
---
- hosts: all
tasks:
- name: install httpd
yum:
name: httpd
state: present
when: ansible_facts['distribution'] == "RedHat" or ansible_facts['distribution_version'] == "7.9" //执行play
[root@localhost project]# ansible-playbook playbook.yaml PLAY [all] **************************************************************************************************************************************************************** TASK [Gathering Facts] ****************************************************************************************************************************************************
ok: [client.example.com] TASK [install httpd] ******************************************************************************************************************************************************
changed: [client.example.com] PLAY RECAP ****************************************************************************************************************************************************************
client.example.com : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
//我当前使用的是RHEL8.1版本
- 演示实例二:or 语句第二种写法
[root@localhost project]# cat playbook.yaml
---
- hosts: all
tasks:
- name: install httpd
yum:
name: httpd
state: present
when: > //这里可以加,也可以不加;>:是允许下面的变量可以换行写
( ansible_facts['distribution'] == "RedHat" )
or
( ansible_facts['distribution_version'] == "7.9 )" //执行play
[root@localhost project]# ansible-playbook playbook.yaml PLAY [all] **************************************************************************************************************************************************************** TASK [Gathering Facts] ****************************************************************************************************************************************************
ok: [client.example.com] TASK [install httpd] ******************************************************************************************************************************************************
changed: [client.example.com] PLAY RECAP ****************************************************************************************************************************************************************
client.example.com : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
- 演示实例三:or 语句的第三种写法(与and语句嵌套使用)
//查看playbook
[root@localhost project]# cat playbook.yaml
---
- hosts: all
tasks:
- name: install httpd
yum:
name: httpd
state: present
when:
( ansible_facts['distribution'] == "RedHat" and ansible_facts['kernel'] == "4.18.0-147.el8.x86_64" )
or
( ansible_facts['distribution_version'] == "7.9" and ansible_facts['distribution_major_version'] == "7" ) //执行play
[root@localhost project]# ansible-playbook playbook.yaml PLAY [all] **************************************************************************************************************************************************************** TASK [Gathering Facts] ****************************************************************************************************************************************************
ok: [client.example.com] TASK [install httpd] ******************************************************************************************************************************************************
changed: [client.example.com] PLAY RECAP ****************************************************************************************************************************************************************
client.example.com : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
三、组合循环和有条件任务
1、使用Loop和When组合使用
- 演示实例:
//查看playbook
[root@localhost project]# cat playbook.yaml
---
- hosts: all
tasks:
- name: install httpd
yum:
name: httpd
state: present
loop: "{{ ansible_facts['mounts'] }}"
when:
- item.mount == "/"
- item.size_available > 50000000000 //执行paly
[root@localhost project]# ansible-playbook playbook.yaml PLAY [all] **************************************************************************************************************************************************************** TASK [Gathering Facts] ****************************************************************************************************************************************************
ok: [client.example.com] TASK [install httpd] ******************************************************************************************************************************************************
changed: [client.example.com] => (item={'mount': '/', 'device': '/dev/mapper/rhel-root', 'fstype': 'xfs', 'options': 'rw,seclabel,relatime,attr2,inode64,noquota', 'size_total': 53660876800, 'size_available': 51805659136, 'block_size': 4096, 'block_total': 13100800, 'block_available': 12647866, 'block_used': 452934, 'inode_total': 26214400, 'inode_available': 26178405, 'inode_used': 35995, 'uuid': '6a525cf5-3f23-4639-81cb-04fcdb764eb6'})
skipping: [client.example.com] => (item={'mount': '/home', 'device': '/dev/mapper/rhel-home', 'fstype': 'xfs', 'options': 'rw,seclabel,relatime,attr2,inode64,noquota', 'size_total': 28922376192, 'size_available': 28686655488, 'block_size': 4096, 'block_total': 7061127, 'block_available': 7003578, 'block_used': 57549, 'inode_total': 14129152, 'inode_available': 14129137, 'inode_used': 15, 'uuid': '2840f839-89b2-4717-b1d0-c74c46d05019'})
skipping: [client.example.com] => (item={'mount': '/boot', 'device': '/dev/nvme0n1p1', 'fstype': 'xfs', 'options': 'rw,seclabel,relatime,attr2,inode64,noquota', 'size_total': 1063256064, 'size_available': 882565120, 'block_size': 4096, 'block_total': 259584, 'block_available': 215470, 'block_used': 44114, 'inode_total': 524288, 'inode_available': 523987, 'inode_used': 301, 'uuid': '234365dc-2262-452e-9cbb-a6acfde04385'})
skipping: [client.example.com] => (item={'mount': '/mnt', 'device': '/dev/sr0', 'fstype': 'iso9660', 'options': 'ro,relatime,nojoliet,check=s,map=n,blocksize=2048', 'size_total': 7851202560, 'size_available': 0, 'block_size': 2048, 'block_total': 3833595, 'block_available': 0, 'block_used': 3833595, 'inode_total': 0, 'inode_available': 0, 'inode_used': 0, 'uuid': '2019-10-15-13-34-03-00'}) PLAY RECAP ****************************************************************************************************************************************************************
client.example.com : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
2、使用Register和When组合使用
- 演示实例:
//查看playbook
[root@localhost project]# cat playbook.yaml
---
- hosts: all
tasks:
- name: install httpd
yum:
name: httpd
state: present
ignore_errors: yes //在运行时,如果出现错误且命令失败,将不会停止,继续执行其他的命令
register: result //将安装成功后的结果注册到result变量中 - name: start httpd
service:
name: httpd
state: started
when: result.rc == 0 //在该变量中匹配到返回值rc=0执行该命令 //执行play
[root@localhost project]# ansible-playbook playbook.yaml PLAY [all] **************************************************************************************************************************************************************** TASK [Gathering Facts] ****************************************************************************************************************************************************
ok: [client.example.com] TASK [install httpd] ******************************************************************************************************************************************************
changed: [client.example.com] TASK [start httpd] ********************************************************************************************************************************************************
changed: [client.example.com] PLAY RECAP ****************************************************************************************************************************************************************
client.example.com : ok=3 changed=2 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
下一篇:实施处理程序
Ansible_编写循环和条件任务的更多相关文章
- python Django教程 之模板渲染、循环、条件判断、常用的标签、过滤器
python3.5 manage.py runserver python Django教程 之模板渲染.循环.条件判断.常用的标签.过滤器 一.Django模板渲染模板 1. 创建一个 zqxt_tm ...
- Java循环和条件
下列程序的输出结果是什么? 1.Java循环和条件 /** * @Title:IuputData.java * @Package:com.you.data * @Description:TODO * ...
- 第二天:python的函 数、循环和条件、类
https://uqer.io/community/share/54c8af17f9f06c276f651a54 第一天学习了Python的基本操作,以及几种主要的容器类型,今天学习python的函数 ...
- Java 控制语句:循环、条件判断
基础很重要,基础很重要,基础很重要.重要的事情说三遍,. 程序设计中的控制语句主要有三种:顺序.分支和循环.我们每天写的代码,除了业务相关,里面会包含大量的控制语句.但是控制语句的基本使用,是否有些坑 ...
- javascript面向对象编程笔记(基本数据类型,数组,循环及条件表达式)
javascript面向对象编程指南 最近在看这本书,以下是我的笔记,仅供参考. 第二章 基本数据类型.数组.循环及条件表达式 2.1 变量 区分大小写 2.3 基本数据类型 数字:包括浮点数与整数 ...
- SQL中循环和条件语句
.if语句使用示例: declare @a int begin print @a end else begin print 'no' end .while语句使用示例: declare @i int ...
- Ansible系列(六):循环和条件判断
本文目录:1. 循环 1.1 with_items迭代列表 1.2 with_dict迭代字典项 1.3 with_fileglob迭代文件 1.4 with_lines迭代行 1.5 with_ne ...
- PHP和JS在循环、条件判断中的不同之处
一.条件判断: php中算 false 的情况 1. boolean:false 2. 整形:0 3.浮点型:0 4.字符串:"" "0"(其他都对) 5.空 ...
- SqlServer中循环和条件语句
if语句使用示例 declare @a int set @a=12 if @a>100 begin ...
随机推荐
- Nodejs入门(二)
Nodejs基础api 1.path path模块提供了很多实用的工具函数,用于处理文件与目录的路径,下面是它的api: normalize 方法可以输出规范格式的path字符串 join 方法用于拼 ...
- 又一起.NET程序挂死, 用 Windbg 抽丝剥茧式的真实案例分析
一:背景 1. 讲故事 前天有位粉丝朋友在后台留言让我帮忙看看他的 Winform程序 UI无响应 + 410线程 到底是啥情况,如下图: 说实话,能看到这些真实案例我是特别喜欢的 ,就像医生看病,光 ...
- SpringCloud LoadBalancer灰度策略实现
如何使用 Spring Cloud 2020 中重磅推荐的负载均衡器 Spring Cloud LoadBalancer (下文简称 SCL),如何扩展负载均衡策略? 你将从本文中获取到答案 快速上手 ...
- YARP实现Dapr服务调用的反向代理
楔子 公司即将新开项目,打算用点时髦的技术,需要探探路.之前没做过微服务项目,没有技术栈方面的积(负)累(债), 干脆就上微软的分布式运行时Dapr......嗯......用来服务发现,然后等测试用 ...
- 1.稀疏数组_java实现
稀疏数组 当一个数组中大部分元素为0,或者为同一个值的数组时,可以使用稀疏数组来保存该数组. 稀疏数组的处理方法是: 记录数组一共有几行几列,有多少个不同的值 把具有不同值的元素行列及值记录在一个小规 ...
- 2-69.x的平方根
题目描述: 解题思路: 计算平方根可以依次通过自然数递增,来判断两者相乘是否为目标值,是一个有序的序列,因此考虑使用二分查找. 由于x=0和1时,就是其本身,单独拿出来.当x>1时,其平方根一定 ...
- Node.js/Vue.js使用jsSHA库进行SHA1/2/3加密
1 概述 jsSHA是一个用JS+TS实现完整SHA系列加密算法的加密库,包括: SHA1 SHA-224/256/384/512 SHA3-224/256/384/512 SHAKE128/256 ...
- User-Agent大全 python
1 # -*-coding:utf-8 -*- 2 3 import random 4 5 # 返回一个随机的请求头 headers 6 def getheaders(): 7 # 各种PC端 8 u ...
- 我自横刀向天笑,手写Spring IOC容器,快来Look Look!
目录 IOC分析 IOC是什么 IOC能够带来什么好处 IOC容器是做什么工作的 IOC容器是否是工厂模式的实例 IOC设计实现 设计IOC需要什么 定义接口 一:Bean工厂接口 二:Bean定义的 ...
- Linux安装MySQL8高版本压缩包(通用)
前言 前段时间领导让我部署测试环境,希望安装高版本的MySQL,过程遇到很多问题,特此记录帮助迷失的人们 下载 MySQL官方下载地址:https://dev.mysql.com/downloads/ ...