Created
September 12, 2018 16:18
-
-
Save btomasini/5572030bd63d73078c10cc3cd59c1f9d to your computer and use it in GitHub Desktop.
Comparison of testinfra versus goss infrastructure tests.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import testinfra.utils.ansible_runner | |
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( | |
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') | |
def test_bind9_installed(host): | |
assert host.package('bind9').is_installed | |
def test_named_conf_options(host): | |
f = host.file('/etc/bind/named.conf.options') | |
assert f.exists | |
assert f.user == 'root' | |
assert f.group == 'bind' | |
assert f.mode == 0o640 | |
assert f.contains('10.11.0.0/24;') | |
assert f.contains('8.8.8.8;') | |
assert f.contains('8.8.4.4;') | |
assert f.contains('dnssec-enable no;') | |
assert f.contains('dnssec-validation no;') | |
def test_named_conf_local(host): | |
f = host.file('/etc/bind/named.conf.local') | |
assert f.exists | |
assert f.user == 'root' | |
assert f.group == 'bind' | |
assert f.mode == 0o640 | |
assert f.contains('zone "zone1.example.com" {') | |
assert f.contains('zone "zone2.example.com" {') | |
assert f.contains('2.2.2.2;') | |
assert f.contains('forward only;') | |
assert f.contains('127.0.0.1 port 8600;') | |
def test_named_is_running(host): | |
o = host.check_output('dig @localhost') | |
assert 'NOERROR' in o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
package: | |
bind9: | |
installed: true | |
file: | |
/etc/bind/named.conf.options: | |
exists: true | |
owner: root | |
group: bind | |
mode: "0640" | |
contains: | |
- '10.11.0.0/24;' | |
- '8.8.8.8;' | |
- '8.8.4.4;' | |
- 'dnssec-enable no;' | |
- 'dnssec-validation no;' | |
/etc/bind/named.conf.local: | |
exists: true | |
owner: root | |
group: bind | |
mode: "0640" | |
contains: | |
- 'zone "zone1.example.com" {' | |
- 'zone "zone2.example.com" {' | |
- '2.2.2.2;' | |
- 'forward only;' | |
- '127.0.0.1 port 8600;' | |
command: | |
"dig @localhost": | |
exit-status: 0 | |
stdout: | |
- NOERROR |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment