目录标题
1. jinja2的用法
2. { {}}的使用
变量:
[root@server4 ~]# cat test.j2
westos python
test jinjia2
test {
{
testvar1}}
测试:
[root@server4 ~]# ansible testB -m template -e "testvar1=haha" -a "src=test.j2 dest=/opt/test"
[root@server3 redis]# cat /opt/test
westos python
test jinjia2
test haha
表达式:
[root@server4 jjia]# cat test1.j2
{
{
1==1}}
{
{
2!=2}}
{
{
2>1}}
{
{
3<4}}
{
{
2>=1}}
测试:
[root@server4 jjia]# ansible testB -m template -a "src=test1.j2 dest=/opt/test"
[root@server3 redis]# cat /opt/test
True
False
True
True
True
逻辑运算:
[root@server4 jjia]# cat test2.j2
{
{
(2>1) or (3<2)}}
{
{
(2>1