Skip to content

Commit 30dfa79

Browse files
authored
Merge pull request #132 from TomasTomecek/fix-130-2
Complete fix for #130 + testing w/ ansible 2.7 and 2.8
2 parents 2c961ce + 57547b2 commit 30dfa79

File tree

5 files changed

+50
-8
lines changed

5 files changed

+50
-8
lines changed

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ build-ab-img: recipe.yml
1111
check:
1212
PYTHONPATH=$(CURDIR) PYTHONDONTWRITEBYTECODE=yes pytest-3 --cov=ansible_bender -l -v $(TEST_TARGET)
1313

14+
check-a-lot:
15+
WITH_TESTS=yes vagrant up --provision
16+
WITH_TESTS=yes vagrant halt
17+
1418
check-in-container:
1519
podman run -ti --rm \
1620
--tmpfs /tmp:rw,exec,nosuid,nodev,size=1000000k \

Vagrantfile

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,36 @@
22
# vi: set ft=ruby :
33

44
Vagrant.configure("2") do |config|
5-
config.vm.box = "fedora/29-cloud-base"
5+
with_tests = ENV["WITH_TESTS"] || "no"
6+
if with_tests == "yes"
7+
config.vm.define "f29" do |f29|
8+
f29.vm.box = "fedora/29-cloud-base"
9+
end
10+
end
11+
12+
config.vm.define "f30" do |f30|
13+
f30.vm.box = "fedora/30-cloud-base"
14+
end
615

716
config.vm.provider "libvirt" do |vb|
8-
# Customize the amount of memory on the VM:
9-
vb.memory = "2048"
17+
vb.memory = "1024"
1018
end
1119

1220
config.vm.provision "ansible" do |a|
13-
# FIXME: it will fail since the playbook expects a container environment
14-
# we should fix it
1521
a.playbook = "recipe.yml"
16-
a.raw_arguments = ["-e", "ansible_python_interpreter=/usr/bin/python3", "--become"]
22+
a.raw_arguments = [
23+
"-vv",
24+
"-e", "ansible_python_interpreter=/usr/bin/python3",
25+
"-e", "project_dir=/vagrant",
26+
"-e", "with_tests=#{with_tests}",
27+
"--become"
28+
]
29+
end
30+
31+
if with_tests == "yes"
32+
config.vm.provision "shell", inline: <<-EOF
33+
cd /vagrant && \
34+
sudo make check
35+
EOF
1736
end
1837
end

ansible.cfg

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[defaults]
2+
retry_files_enabled = false
3+
# enable_task_debugger = True
4+
# dense,debug,unixy,yaml,minimal
5+
stdout_callback = debug
6+
# strategy = debug

ansible_bender/callback_plugins/snapshoter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def _snapshot(self, task_result):
3636
3737
:param task_result: instance of TaskResult
3838
"""
39-
if task_result._task.action == "setup":
39+
if task_result._task.action in ["setup", "gather_facts"]:
4040
# we ignore setup
4141
return
4242
if task_result.is_failed() or task_result._result.get("rc", 0) > 0:

recipe.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
vars:
55
test_mode: no # yes - test in CI, no - build an image
66
project_dir: /src
7+
with_tests: no # yes - run test suite
78
ansible_bender:
89
target_image:
910
workging_dir: /src
@@ -12,6 +13,11 @@
1213
volumes:
1314
- "{{ playbook_dir }}:/src"
1415
tasks:
16+
- name: upgrade all packages
17+
dnf:
18+
name: "*"
19+
state: latest
20+
when: with_tests == "yes"
1521
- name: Install all packages needed to hack on ab.
1622
dnf:
1723
name:
@@ -33,6 +39,11 @@
3339
- python3-jsonschema
3440
- docker # one test uses it
3541
state: present
42+
- name: Start dockerd
43+
systemd:
44+
name: docker
45+
state: started
46+
when: with_tests == "yes"
3647
- name: Install latest twine for sake of check command
3748
pip:
3849
name:
@@ -49,6 +60,7 @@
4960
path: /etc/containers/storage.conf
5061
regexp: '^graphroot = '
5162
line: 'graphroot = "/tmp/containers"'
63+
when: with_tests == "no"
5264
- name: stat /src
5365
stat:
5466
path: /src
@@ -69,15 +81,16 @@
6981
src: /usr/share/containers/libpod.conf
7082
dest: /etc/containers/libpod.conf
7183
remote_src: yes
84+
when: with_tests == "no"
7285
- name: Change cgroup driver to cgroupfs.
7386
lineinfile:
7487
path: /etc/containers/libpod.conf
7588
regexp: '^cgroup_manager = '
7689
line: 'cgroup_manager = "cgroupfs"'
90+
when: with_tests == "no"
7791
# this requires sources mounted inside at /src
7892
- name: Install ansible-bender from the current working directory
7993
pip:
8094
name: '{{ project_dir }}'
8195
tags:
8296
- no-cache
83-

0 commit comments

Comments
 (0)