Skip to content

Commit

Permalink
Merge pull request #132 from TomasTomecek/fix-130-2
Browse files Browse the repository at this point in the history
Complete fix for #130 + testing w/ ansible 2.7 and 2.8
  • Loading branch information
TomasTomecek authored May 24, 2019
2 parents 2c961ce + 57547b2 commit 30dfa79
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 8 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ build-ab-img: recipe.yml
check:
PYTHONPATH=$(CURDIR) PYTHONDONTWRITEBYTECODE=yes pytest-3 --cov=ansible_bender -l -v $(TEST_TARGET)

check-a-lot:
WITH_TESTS=yes vagrant up --provision
WITH_TESTS=yes vagrant halt

check-in-container:
podman run -ti --rm \
--tmpfs /tmp:rw,exec,nosuid,nodev,size=1000000k \
Expand Down
31 changes: 25 additions & 6 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,36 @@
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
config.vm.box = "fedora/29-cloud-base"
with_tests = ENV["WITH_TESTS"] || "no"
if with_tests == "yes"
config.vm.define "f29" do |f29|
f29.vm.box = "fedora/29-cloud-base"
end
end

config.vm.define "f30" do |f30|
f30.vm.box = "fedora/30-cloud-base"
end

config.vm.provider "libvirt" do |vb|
# Customize the amount of memory on the VM:
vb.memory = "2048"
vb.memory = "1024"
end

config.vm.provision "ansible" do |a|
# FIXME: it will fail since the playbook expects a container environment
# we should fix it
a.playbook = "recipe.yml"
a.raw_arguments = ["-e", "ansible_python_interpreter=/usr/bin/python3", "--become"]
a.raw_arguments = [
"-vv",
"-e", "ansible_python_interpreter=/usr/bin/python3",
"-e", "project_dir=/vagrant",
"-e", "with_tests=#{with_tests}",
"--become"
]
end

if with_tests == "yes"
config.vm.provision "shell", inline: <<-EOF
cd /vagrant && \
sudo make check
EOF
end
end
6 changes: 6 additions & 0 deletions ansible.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[defaults]
retry_files_enabled = false
# enable_task_debugger = True
# dense,debug,unixy,yaml,minimal
stdout_callback = debug
# strategy = debug
2 changes: 1 addition & 1 deletion ansible_bender/callback_plugins/snapshoter.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def _snapshot(self, task_result):
:param task_result: instance of TaskResult
"""
if task_result._task.action == "setup":
if task_result._task.action in ["setup", "gather_facts"]:
# we ignore setup
return
if task_result.is_failed() or task_result._result.get("rc", 0) > 0:
Expand Down
15 changes: 14 additions & 1 deletion recipe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
vars:
test_mode: no # yes - test in CI, no - build an image
project_dir: /src
with_tests: no # yes - run test suite
ansible_bender:
target_image:
workging_dir: /src
Expand All @@ -12,6 +13,11 @@
volumes:
- "{{ playbook_dir }}:/src"
tasks:
- name: upgrade all packages
dnf:
name: "*"
state: latest
when: with_tests == "yes"
- name: Install all packages needed to hack on ab.
dnf:
name:
Expand All @@ -33,6 +39,11 @@
- python3-jsonschema
- docker # one test uses it
state: present
- name: Start dockerd
systemd:
name: docker
state: started
when: with_tests == "yes"
- name: Install latest twine for sake of check command
pip:
name:
Expand All @@ -49,6 +60,7 @@
path: /etc/containers/storage.conf
regexp: '^graphroot = '
line: 'graphroot = "/tmp/containers"'
when: with_tests == "no"
- name: stat /src
stat:
path: /src
Expand All @@ -69,15 +81,16 @@
src: /usr/share/containers/libpod.conf
dest: /etc/containers/libpod.conf
remote_src: yes
when: with_tests == "no"
- name: Change cgroup driver to cgroupfs.
lineinfile:
path: /etc/containers/libpod.conf
regexp: '^cgroup_manager = '
line: 'cgroup_manager = "cgroupfs"'
when: with_tests == "no"
# this requires sources mounted inside at /src
- name: Install ansible-bender from the current working directory
pip:
name: '{{ project_dir }}'
tags:
- no-cache

0 comments on commit 30dfa79

Please sign in to comment.