ansible: tests for sudo behaviour; closes #143.
parent
4a61527774
commit
98ee3e177a
@ -0,0 +1,6 @@
|
||||
|
||||
- import_playbook: sudo_flags_failure.yml
|
||||
- import_playbook: sudo_nonexistent.yml
|
||||
- import_playbook: sudo_nopassword.yml
|
||||
- import_playbook: sudo_password.yml
|
||||
- import_playbook: sudo_requiretty.yml
|
@ -0,0 +1,23 @@
|
||||
- hosts: all
|
||||
any_errors_fatal: true
|
||||
tasks:
|
||||
- name: integration/become/sudo_flags_failure.yml
|
||||
assert:
|
||||
that: true
|
||||
|
||||
- name: Verify behaviour for bad sudo flags.
|
||||
shell: whoami
|
||||
become: true
|
||||
ignore_errors: true
|
||||
register: out
|
||||
vars:
|
||||
ansible_become_flags: --derps
|
||||
|
||||
- debug: msg={{out}}
|
||||
- name: Verify raw module output.
|
||||
assert:
|
||||
that:
|
||||
- out.failed
|
||||
- |
|
||||
('sudo: no such option: --derps' in out.msg) or
|
||||
("sudo: unrecognized option `--derps'" in out.module_stderr)
|
@ -0,0 +1,21 @@
|
||||
- hosts: all
|
||||
any_errors_fatal: true
|
||||
tasks:
|
||||
- name: integration/become/sudo_nonexistent.yml
|
||||
assert:
|
||||
that: true
|
||||
|
||||
- name: Verify behaviour for non-existent accounts.
|
||||
shell: whoami
|
||||
become: true
|
||||
become_user: slartibartfast
|
||||
ignore_errors: true
|
||||
register: out
|
||||
|
||||
- name: Verify raw module output.
|
||||
assert:
|
||||
that: |
|
||||
out.failed and (
|
||||
('sudo: unknown user: slartibartfast' in out.msg) or
|
||||
('sudo: unknown user: slartibartfast' in out.module_stderr)
|
||||
)
|
@ -0,0 +1,26 @@
|
||||
# Verify passwordless sudo behaviour in various cases.
|
||||
|
||||
- hosts: all
|
||||
any_errors_fatal: true
|
||||
tasks:
|
||||
- name: integration/become/sudo_basic.yml
|
||||
assert:
|
||||
that: true
|
||||
|
||||
- name: Verify we aren't root
|
||||
shell: whoami
|
||||
register: out
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- out.stdout != 'root'
|
||||
|
||||
- name: Ensure passwordless sudo to root succeeds.
|
||||
shell: whoami
|
||||
become: true
|
||||
become_user: root
|
||||
register: out
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- out.stdout == 'root'
|
@ -0,0 +1,50 @@
|
||||
# Verify passwordful sudo behaviour
|
||||
|
||||
- hosts: all
|
||||
any_errors_fatal: true
|
||||
tasks:
|
||||
- name: integration/become/sudo_password.yml
|
||||
assert:
|
||||
that: true
|
||||
|
||||
- name: Ensure password sudo absent.
|
||||
shell: whoami
|
||||
become: true
|
||||
become_user: mitogen__pw_required
|
||||
register: out
|
||||
ignore_errors: true
|
||||
|
||||
- assert:
|
||||
that: |
|
||||
out.failed and (
|
||||
('password is required' in out.msg) or
|
||||
('password is required' in out.module_stderr)
|
||||
)
|
||||
|
||||
- name: Ensure password sudo incorrect.
|
||||
shell: whoami
|
||||
become: true
|
||||
become_user: mitogen__pw_required
|
||||
register: out
|
||||
vars:
|
||||
ansible_become_pass: nopes
|
||||
ignore_errors: true
|
||||
|
||||
- assert:
|
||||
that: |
|
||||
out.failed and (
|
||||
('Incorrect sudo password' in out.msg) or
|
||||
('sudo password is incorrect' in out.msg)
|
||||
)
|
||||
|
||||
- name: Ensure password sudo succeeds.
|
||||
shell: whoami
|
||||
become: true
|
||||
become_user: mitogen__pw_required
|
||||
register: out
|
||||
vars:
|
||||
ansible_become_pass: mitogen__password
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- out.stdout == 'mitogen__pw_required'
|
@ -0,0 +1,37 @@
|
||||
# Verify requiretty support
|
||||
|
||||
- hosts: all
|
||||
any_errors_fatal: true
|
||||
tasks:
|
||||
- name: integration/become/sudo_requiretty.yml
|
||||
assert:
|
||||
that: true
|
||||
|
||||
- name: Verify we can login to a non-passworded requiretty account
|
||||
shell: whoami
|
||||
become: true
|
||||
become_user: mitogen__require_tty
|
||||
register: out
|
||||
when: is_mitogen
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- out.stdout == 'mitogen__require_tty'
|
||||
when: is_mitogen
|
||||
|
||||
|
||||
# ---------------
|
||||
|
||||
- name: Verify we can login to a passworded requiretty account
|
||||
shell: whoami
|
||||
become: true
|
||||
become_user: mitogen__require_tty_pw_required
|
||||
vars:
|
||||
ansible_become_pass: mitogen__password
|
||||
register: out
|
||||
when: is_mitogen
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- out.stdout == 'mitogen__require_tty_pw_required'
|
||||
when: is_mitogen
|
Loading…
Reference in New Issue