mirror of https://github.com/ansible/ansible.git
Add check mode indicators at the beginning and the end of the playbook, play, and task (#49432)
* Add integration tests for default callback check mode markerspull/59592/head
parent
a5d409a8b2
commit
3c8838f0f7
@ -0,0 +1,2 @@
|
||||
minor_changes:
|
||||
- Add new option to default standard out callback plugin, ``ANSIBLE_CHECK_MODE_MARKERS``, which adds check mode markers (``DRY RUN``, ``CHECK_MODE``) to the output when running in check mode. It is off by default.
|
||||
@ -0,0 +1,2 @@
|
||||
+ ansible-playbook -i inventory --check test_dryrun.yml
|
||||
++ set +x
|
||||
@ -0,0 +1,78 @@
|
||||
|
||||
DRY RUN ************************************************************************
|
||||
|
||||
PLAY [A common play] [CHECK MODE] **********************************************
|
||||
|
||||
TASK [debug] [CHECK MODE] ******************************************************
|
||||
ok: [testhost] => {
|
||||
"msg": "ansible_check_mode: True"
|
||||
}
|
||||
|
||||
TASK [Command] [CHECK MODE] ****************************************************
|
||||
skipping: [testhost]
|
||||
|
||||
TASK [Command with check_mode: false] ******************************************
|
||||
changed: [testhost]
|
||||
|
||||
TASK [Command with check_mode: true] [CHECK MODE] ******************************
|
||||
skipping: [testhost]
|
||||
|
||||
PLAY [Play with check_mode: true (runs always in check_mode)] [CHECK MODE] *****
|
||||
|
||||
TASK [debug] [CHECK MODE] ******************************************************
|
||||
ok: [testhost] => {
|
||||
"msg": "ansible_check_mode: True"
|
||||
}
|
||||
|
||||
TASK [Command] [CHECK MODE] ****************************************************
|
||||
skipping: [testhost]
|
||||
|
||||
TASK [Command with check_mode: false] ******************************************
|
||||
changed: [testhost]
|
||||
|
||||
TASK [Command with check_mode: true] [CHECK MODE] ******************************
|
||||
skipping: [testhost]
|
||||
|
||||
PLAY [Play with check_mode: false (runs always in wet mode)] *******************
|
||||
|
||||
TASK [debug] *******************************************************************
|
||||
ok: [testhost] => {
|
||||
"msg": "ansible_check_mode: True"
|
||||
}
|
||||
|
||||
TASK [Command] *****************************************************************
|
||||
changed: [testhost]
|
||||
|
||||
TASK [Command with check_mode: false] ******************************************
|
||||
changed: [testhost]
|
||||
|
||||
TASK [Command with check_mode: true] [CHECK MODE] ******************************
|
||||
skipping: [testhost]
|
||||
|
||||
PLAY [Play with a block with check_mode: true] [CHECK MODE] ********************
|
||||
|
||||
TASK [Command] [CHECK MODE] ****************************************************
|
||||
skipping: [testhost]
|
||||
|
||||
TASK [Command with check_mode: false] ******************************************
|
||||
changed: [testhost]
|
||||
|
||||
TASK [Command with check_mode: true] [CHECK MODE] ******************************
|
||||
skipping: [testhost]
|
||||
|
||||
PLAY [Play with a block with check_mode: false] [CHECK MODE] *******************
|
||||
|
||||
TASK [Command] *****************************************************************
|
||||
changed: [testhost]
|
||||
|
||||
TASK [Command with check_mode: false] ******************************************
|
||||
changed: [testhost]
|
||||
|
||||
TASK [Command with check_mode: true] [CHECK MODE] ******************************
|
||||
skipping: [testhost]
|
||||
|
||||
PLAY RECAP *********************************************************************
|
||||
testhost : ok=10 changed=7 unreachable=0 failed=0 skipped=8 rescued=0 ignored=0
|
||||
|
||||
|
||||
DRY RUN ************************************************************************
|
||||
@ -0,0 +1,2 @@
|
||||
+ ansible-playbook -i inventory test_dryrun.yml
|
||||
++ set +x
|
||||
@ -0,0 +1,74 @@
|
||||
|
||||
PLAY [A common play] ***********************************************************
|
||||
|
||||
TASK [debug] *******************************************************************
|
||||
ok: [testhost] => {
|
||||
"msg": "ansible_check_mode: False"
|
||||
}
|
||||
|
||||
TASK [Command] *****************************************************************
|
||||
changed: [testhost]
|
||||
|
||||
TASK [Command with check_mode: false] ******************************************
|
||||
changed: [testhost]
|
||||
|
||||
TASK [Command with check_mode: true] [CHECK MODE] ******************************
|
||||
skipping: [testhost]
|
||||
|
||||
PLAY [Play with check_mode: true (runs always in check_mode)] [CHECK MODE] *****
|
||||
|
||||
TASK [debug] [CHECK MODE] ******************************************************
|
||||
ok: [testhost] => {
|
||||
"msg": "ansible_check_mode: False"
|
||||
}
|
||||
|
||||
TASK [Command] [CHECK MODE] ****************************************************
|
||||
skipping: [testhost]
|
||||
|
||||
TASK [Command with check_mode: false] ******************************************
|
||||
changed: [testhost]
|
||||
|
||||
TASK [Command with check_mode: true] [CHECK MODE] ******************************
|
||||
skipping: [testhost]
|
||||
|
||||
PLAY [Play with check_mode: false (runs always in wet mode)] *******************
|
||||
|
||||
TASK [debug] *******************************************************************
|
||||
ok: [testhost] => {
|
||||
"msg": "ansible_check_mode: False"
|
||||
}
|
||||
|
||||
TASK [Command] *****************************************************************
|
||||
changed: [testhost]
|
||||
|
||||
TASK [Command with check_mode: false] ******************************************
|
||||
changed: [testhost]
|
||||
|
||||
TASK [Command with check_mode: true] [CHECK MODE] ******************************
|
||||
skipping: [testhost]
|
||||
|
||||
PLAY [Play with a block with check_mode: true] *********************************
|
||||
|
||||
TASK [Command] [CHECK MODE] ****************************************************
|
||||
skipping: [testhost]
|
||||
|
||||
TASK [Command with check_mode: false] ******************************************
|
||||
changed: [testhost]
|
||||
|
||||
TASK [Command with check_mode: true] [CHECK MODE] ******************************
|
||||
skipping: [testhost]
|
||||
|
||||
PLAY [Play with a block with check_mode: false] ********************************
|
||||
|
||||
TASK [Command] *****************************************************************
|
||||
changed: [testhost]
|
||||
|
||||
TASK [Command with check_mode: false] ******************************************
|
||||
changed: [testhost]
|
||||
|
||||
TASK [Command with check_mode: true] [CHECK MODE] ******************************
|
||||
skipping: [testhost]
|
||||
|
||||
PLAY RECAP *********************************************************************
|
||||
testhost : ok=11 changed=8 unreachable=0 failed=0 skipped=7 rescued=0 ignored=0
|
||||
|
||||
@ -0,0 +1,2 @@
|
||||
+ ansible-playbook -i inventory --check test_dryrun.yml
|
||||
++ set +x
|
||||
@ -0,0 +1,74 @@
|
||||
|
||||
PLAY [A common play] ***********************************************************
|
||||
|
||||
TASK [debug] *******************************************************************
|
||||
ok: [testhost] => {
|
||||
"msg": "ansible_check_mode: True"
|
||||
}
|
||||
|
||||
TASK [Command] *****************************************************************
|
||||
skipping: [testhost]
|
||||
|
||||
TASK [Command with check_mode: false] ******************************************
|
||||
changed: [testhost]
|
||||
|
||||
TASK [Command with check_mode: true] *******************************************
|
||||
skipping: [testhost]
|
||||
|
||||
PLAY [Play with check_mode: true (runs always in check_mode)] ******************
|
||||
|
||||
TASK [debug] *******************************************************************
|
||||
ok: [testhost] => {
|
||||
"msg": "ansible_check_mode: True"
|
||||
}
|
||||
|
||||
TASK [Command] *****************************************************************
|
||||
skipping: [testhost]
|
||||
|
||||
TASK [Command with check_mode: false] ******************************************
|
||||
changed: [testhost]
|
||||
|
||||
TASK [Command with check_mode: true] *******************************************
|
||||
skipping: [testhost]
|
||||
|
||||
PLAY [Play with check_mode: false (runs always in wet mode)] *******************
|
||||
|
||||
TASK [debug] *******************************************************************
|
||||
ok: [testhost] => {
|
||||
"msg": "ansible_check_mode: True"
|
||||
}
|
||||
|
||||
TASK [Command] *****************************************************************
|
||||
changed: [testhost]
|
||||
|
||||
TASK [Command with check_mode: false] ******************************************
|
||||
changed: [testhost]
|
||||
|
||||
TASK [Command with check_mode: true] *******************************************
|
||||
skipping: [testhost]
|
||||
|
||||
PLAY [Play with a block with check_mode: true] *********************************
|
||||
|
||||
TASK [Command] *****************************************************************
|
||||
skipping: [testhost]
|
||||
|
||||
TASK [Command with check_mode: false] ******************************************
|
||||
changed: [testhost]
|
||||
|
||||
TASK [Command with check_mode: true] *******************************************
|
||||
skipping: [testhost]
|
||||
|
||||
PLAY [Play with a block with check_mode: false] ********************************
|
||||
|
||||
TASK [Command] *****************************************************************
|
||||
changed: [testhost]
|
||||
|
||||
TASK [Command with check_mode: false] ******************************************
|
||||
changed: [testhost]
|
||||
|
||||
TASK [Command with check_mode: true] *******************************************
|
||||
skipping: [testhost]
|
||||
|
||||
PLAY RECAP *********************************************************************
|
||||
testhost : ok=10 changed=7 unreachable=0 failed=0 skipped=8 rescued=0 ignored=0
|
||||
|
||||
@ -0,0 +1,2 @@
|
||||
+ ansible-playbook -i inventory test_dryrun.yml
|
||||
++ set +x
|
||||
@ -0,0 +1,74 @@
|
||||
|
||||
PLAY [A common play] ***********************************************************
|
||||
|
||||
TASK [debug] *******************************************************************
|
||||
ok: [testhost] => {
|
||||
"msg": "ansible_check_mode: False"
|
||||
}
|
||||
|
||||
TASK [Command] *****************************************************************
|
||||
changed: [testhost]
|
||||
|
||||
TASK [Command with check_mode: false] ******************************************
|
||||
changed: [testhost]
|
||||
|
||||
TASK [Command with check_mode: true] *******************************************
|
||||
skipping: [testhost]
|
||||
|
||||
PLAY [Play with check_mode: true (runs always in check_mode)] ******************
|
||||
|
||||
TASK [debug] *******************************************************************
|
||||
ok: [testhost] => {
|
||||
"msg": "ansible_check_mode: False"
|
||||
}
|
||||
|
||||
TASK [Command] *****************************************************************
|
||||
skipping: [testhost]
|
||||
|
||||
TASK [Command with check_mode: false] ******************************************
|
||||
changed: [testhost]
|
||||
|
||||
TASK [Command with check_mode: true] *******************************************
|
||||
skipping: [testhost]
|
||||
|
||||
PLAY [Play with check_mode: false (runs always in wet mode)] *******************
|
||||
|
||||
TASK [debug] *******************************************************************
|
||||
ok: [testhost] => {
|
||||
"msg": "ansible_check_mode: False"
|
||||
}
|
||||
|
||||
TASK [Command] *****************************************************************
|
||||
changed: [testhost]
|
||||
|
||||
TASK [Command with check_mode: false] ******************************************
|
||||
changed: [testhost]
|
||||
|
||||
TASK [Command with check_mode: true] *******************************************
|
||||
skipping: [testhost]
|
||||
|
||||
PLAY [Play with a block with check_mode: true] *********************************
|
||||
|
||||
TASK [Command] *****************************************************************
|
||||
skipping: [testhost]
|
||||
|
||||
TASK [Command with check_mode: false] ******************************************
|
||||
changed: [testhost]
|
||||
|
||||
TASK [Command with check_mode: true] *******************************************
|
||||
skipping: [testhost]
|
||||
|
||||
PLAY [Play with a block with check_mode: false] ********************************
|
||||
|
||||
TASK [Command] *****************************************************************
|
||||
changed: [testhost]
|
||||
|
||||
TASK [Command with check_mode: false] ******************************************
|
||||
changed: [testhost]
|
||||
|
||||
TASK [Command with check_mode: true] *******************************************
|
||||
skipping: [testhost]
|
||||
|
||||
PLAY RECAP *********************************************************************
|
||||
testhost : ok=11 changed=8 unreachable=0 failed=0 skipped=7 rescued=0 ignored=0
|
||||
|
||||
@ -0,0 +1,93 @@
|
||||
---
|
||||
- name: A common play
|
||||
hosts: testhost
|
||||
gather_facts: no
|
||||
tasks:
|
||||
- debug:
|
||||
msg: 'ansible_check_mode: {{ansible_check_mode}}'
|
||||
|
||||
- name: Command
|
||||
command: ls -l
|
||||
|
||||
- name: "Command with check_mode: false"
|
||||
command: ls -l
|
||||
check_mode: false
|
||||
|
||||
- name: "Command with check_mode: true"
|
||||
command: ls -l
|
||||
check_mode: true
|
||||
|
||||
|
||||
- name: "Play with check_mode: true (runs always in check_mode)"
|
||||
hosts: testhost
|
||||
gather_facts: no
|
||||
check_mode: true
|
||||
tasks:
|
||||
- debug:
|
||||
msg: 'ansible_check_mode: {{ansible_check_mode}}'
|
||||
|
||||
- name: Command
|
||||
command: ls -l
|
||||
|
||||
- name: "Command with check_mode: false"
|
||||
command: ls -l
|
||||
check_mode: false
|
||||
|
||||
- name: "Command with check_mode: true"
|
||||
command: ls -l
|
||||
check_mode: true
|
||||
|
||||
|
||||
- name: "Play with check_mode: false (runs always in wet mode)"
|
||||
hosts: testhost
|
||||
gather_facts: no
|
||||
check_mode: false
|
||||
tasks:
|
||||
- debug:
|
||||
msg: 'ansible_check_mode: {{ansible_check_mode}}'
|
||||
|
||||
- name: Command
|
||||
command: ls -l
|
||||
|
||||
- name: "Command with check_mode: false"
|
||||
command: ls -l
|
||||
check_mode: false
|
||||
|
||||
- name: "Command with check_mode: true"
|
||||
command: ls -l
|
||||
check_mode: true
|
||||
|
||||
|
||||
- name: "Play with a block with check_mode: true"
|
||||
hosts: testhost
|
||||
gather_facts: no
|
||||
tasks:
|
||||
- block:
|
||||
- name: Command
|
||||
command: ls -l
|
||||
|
||||
- name: "Command with check_mode: false"
|
||||
command: ls -l
|
||||
check_mode: false
|
||||
|
||||
- name: "Command with check_mode: true"
|
||||
command: ls -l
|
||||
check_mode: true
|
||||
check_mode: true
|
||||
|
||||
- name: "Play with a block with check_mode: false"
|
||||
hosts: testhost
|
||||
gather_facts: no
|
||||
tasks:
|
||||
- block:
|
||||
- name: Command
|
||||
command: ls -l
|
||||
|
||||
- name: "Command with check_mode: false"
|
||||
command: ls -l
|
||||
check_mode: false
|
||||
|
||||
- name: "Command with check_mode: true"
|
||||
command: ls -l
|
||||
check_mode: true
|
||||
check_mode: false
|
||||
Loading…
Reference in New Issue