Content #
aligned属性规定变量或者结构体成员的最小对齐格式,以字节为单位。
struct qib_user_info {
__u32 spu_userversion;
__u64 spu_base_info;
} __aligned(8);
编译器以8字节对齐的方式来分配qib_user_info这个数据结构。
零长数组 case关键字支持范围匹配 Referring to a Type with typeof 可变参数宏 元素编号 当前函数名 asmlinkage UL后缀修饰
只要条件允许,ansible模块会尽量避免修改主机的东西。然而,改变有时是不可避免的。为了帮助ansible更好地保证幂等性,可以通过添加creates或 removes参数。
如果有creates参数,那么在该参数指定的文件已经存在的情况下,命令不会被执行。removes参数正好与之相反,如:
ansible machinename -m command -a 'rm -rf /tmp/testing removes=/tmp/testing'
用file模块来实现,可以不用removes参数。
ansible machinename -m file -a 'path=/tmp/testing state=absent'
ens3:
dhcp4: true
match:
macaddress: "{{ hostvars[inventory_hostname]['ansible_default_ipv4']['macaddress'] }}"
mtu: 1500
set-name: ens3
routing-policy:
{% for server in servers -%}
- from: {{ server.ipv4 }}
table: table_{{ server.ipv4.split('.')[-1]}}
{% endfor %}
routes:
{% for server in servers -%}
- to: default
via: {{ tun1_gateway }}
dev: tun1
table: table_{{ server.ipv4.split('.')[-1]}}
{% endfor %}
模板的缩进位置会影响到生成的文本的缩进。使用"-%}“会移除右大括号后所有的空白字符。同样,”{%-“则会移除左大括号之前的空白字符。 endfor的右侧若使用减号,则会导致后续行的缩进出错。
jinja2文档中查阅 Template Designer Documentation.
changed_when: false
用于告诉ansible,本任务没有对主机造成影响(改变文件或安装软件等)。
...