第五十八条 违反关于社会生活噪声污染防治的法律规定,制造噪声干扰他人正常生活的,处警告;警告后不改正的,处二百元以上五百元以下罚款
ansible register 无视when 条件执行
先来看一段ansible代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
- name: test hosts: localhost gather_facts: no vars: test_name: 'real_name' flag: false tasks: - name: retrieve node's hostname shell: "hostname" register: test_name when: flag | bool - debug: var: test_name |
正常来说,我们认为会输出结果会是’real_name’,因为第一个任务因为when的条件判断并没有执行 但是,结果是什么呢?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
ansible-playbook 1.yaml [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all' PLAY [test] ************************************************************************************************************************************************************************* TASK [retrieve node's hostname] ***************************************************************************************************************************************************** skipping: [localhost] TASK [debug] ************************************************************************************************************************************************************************ ok: [localhost] => { "test_name": { "changed": false, "skip_reason": "Conditional result was False", "skipped": true } } PLAY RECAP ************************************************************************************************************************************************************************** localhost : ok=1 changed=0 unreachable=0 failed=0 |
并没有,难道是skip了?……