Skip to content

Commit

Permalink
More DRY
Browse files Browse the repository at this point in the history
  • Loading branch information
tersmitten committed Jan 12, 2021
1 parent ae778d0 commit cfeb9db
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 54 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ RUN rm -rf $HOME/.cache
# ansible
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y gcc libffi-dev libssl-dev net-tools iproute2 ethtool && \
apt-get clean
RUN pip install ansible==2.9.14
RUN pip install ansible==2.9.15
RUN rm -rf $HOME/.cache

# provision
Expand Down
5 changes: 0 additions & 5 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@ Vagrant.configure("2") do |config|

vms.vm.network :private_network, ip: box[:ip]

# TODO: Cleanup
vms.vm.provision :shell do |shell|
shell.path = "tests/vagrant.sh"
end

vms.vm.provision :ansible do |ansible|
ansible.playbook = "tests/vagrant.yml"
ansible.verbose = "vv"
Expand Down
6 changes: 3 additions & 3 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
- name: Converge
hosts: all
become: true
pre_tasks:
- name: include vars
include_vars: "{{ playbook_dir }}/../../tests/vars/main.yml"
roles:
- ../../../
vars:
snmpd_agent_address:
- "udp:{{ ansible_lo['ipv4']['address'] }}:10161"
18 changes: 5 additions & 13 deletions molecule/default/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,8 @@
- name: Prepare
hosts: all
become: true
tasks:
- name: Enable non-free
apt_repository:
repo: "{{ item.type }} {{ item.url }} {{ item.component }}"
filename: non-free
with_items:
- type: deb
url: "http://ftp.nl.debian.org/debian/ {{ ansible_distribution_release }}"
component: contrib non-free
- type: deb-src
url: "http://ftp.nl.debian.org/debian/ {{ ansible_distribution_release }}"
component: contrib non-free
when: ansible_distribution == 'Debian'
pre_tasks:
- name: include vars
include_vars: "{{ playbook_dir }}/../../tests/vars/main.yml"
- name: include tasks
include: "{{ playbook_dir }}/../../tests/tasks/pre.yml"
14 changes: 14 additions & 0 deletions tests/tasks/pre.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# pre test file for snmpd
---
- name: enable non-free
apt_repository:
repo: "{{ item.type }} {{ item.url }} {{ item.component }}"
filename: non-free
with_items:
- type: deb
url: "http://ftp.nl.debian.org/debian/ {{ ansible_distribution_release }}"
component: contrib non-free
- type: deb-src
url: "http://ftp.nl.debian.org/debian/ {{ ansible_distribution_release }}"
component: contrib non-free
when: ansible_distribution == 'Debian'
8 changes: 5 additions & 3 deletions tests/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
- hosts: localhost
connection: local
become: true
pre_tasks:
- name: include vars
include_vars: "{{ playbook_dir }}/vars/main.yml"
- name: include tasks
include: "{{ playbook_dir }}/tasks/pre.yml"
roles:
- ../../
vars:
snmpd_agent_address:
- "udp:{{ ansible_lo['ipv4']['address'] }}:10161"
29 changes: 0 additions & 29 deletions tests/vagrant.sh

This file was deleted.

3 changes: 3 additions & 0 deletions tests/vagrant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
- hosts: all
remote_user: vagrant
become: true
pre_tasks:
- name: include tasks
include: "{{ playbook_dir }}/tasks/pre.yml"
roles:
- ../../
4 changes: 4 additions & 0 deletions tests/vars/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# vars file for snmpd
---
snmpd_agent_address:
- "udp:{{ ansible_lo['ipv4']['address'] }}:10161"

0 comments on commit cfeb9db

Please sign in to comment.