Ansible IPv6無効化のテストコード

環境
RHEL8.6
Ansible
Serverspec

構文
1.ipv6無効化を有効する

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
sysctl:
name: net.ipv6.conf.all.disable_ipv6
sysctl: name: net.ipv6.conf.all.disable_ipv6
sysctl:
  name: net.ipv6.conf.all.disable_ipv6

2.ipv6無効化のテストコード

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
describe command('ip a') do
コード
end
describe command('ip a') do コード end
describe command('ip a') do
コード
end

操作例
1.playbookの定義コード

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
- name: "set ipv6 disable"
sysctl:
name: net.ipv6.conf.all.disable_ipv6
value: '1'
sysctl_set: yes
- name: "set ipv6 disable" sysctl: name: net.ipv6.conf.all.disable_ipv6 value: '1' sysctl_set: yes
- name: "set ipv6 disable"
  sysctl:
    name: net.ipv6.conf.all.disable_ipv6
    value: '1'
    sysctl_set: yes

2.serverspecテストコード

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
describe command('ip a') do
its(:stdout) { is_expected.to_not match(/inet6/) }
end
describe command('ip a') do its(:stdout) { is_expected.to_not match(/inet6/) } end
describe command('ip a') do
  its(:stdout) { is_expected.to_not match(/inet6/) }
end

 

Ansible

Posted by arkgame