From 7baf873320cc6dfb5aaada52adb160ddc308afc2 Mon Sep 17 00:00:00 2001 From: Tomas Tomecek Date: Fri, 24 May 2019 21:06:44 +0200 Subject: [PATCH 1/2] ansible 2.8: setup & gather_facts complete fix Signed-off-by: Tomas Tomecek --- ansible_bender/callback_plugins/snapshoter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ansible_bender/callback_plugins/snapshoter.py b/ansible_bender/callback_plugins/snapshoter.py index c4849bf..020cb9c 100644 --- a/ansible_bender/callback_plugins/snapshoter.py +++ b/ansible_bender/callback_plugins/snapshoter.py @@ -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: From 57547b2c63d5058b74946ae1dd523b84fd8aa8ad Mon Sep 17 00:00:00 2001 From: Tomas Tomecek Date: Fri, 24 May 2019 21:11:36 +0200 Subject: [PATCH 2/2] test bender in 2 vagrant VMs: F29 and F30 Signed-off-by: Tomas Tomecek --- Makefile | 4 ++++ Vagrantfile | 31 +++++++++++++++++++++++++------ ansible.cfg | 6 ++++++ recipe.yml | 15 ++++++++++++++- 4 files changed, 49 insertions(+), 7 deletions(-) create mode 100644 ansible.cfg diff --git a/Makefile b/Makefile index d2873a6..80f1382 100644 --- a/Makefile +++ b/Makefile @@ -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 \ diff --git a/Vagrantfile b/Vagrantfile index d30752e..37b0834 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -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 diff --git a/ansible.cfg b/ansible.cfg new file mode 100644 index 0000000..168ef51 --- /dev/null +++ b/ansible.cfg @@ -0,0 +1,6 @@ +[defaults] +retry_files_enabled = false +# enable_task_debugger = True +# dense,debug,unixy,yaml,minimal +stdout_callback = debug +# strategy = debug diff --git a/recipe.yml b/recipe.yml index b06568c..43f13ae 100644 --- a/recipe.yml +++ b/recipe.yml @@ -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 @@ -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: @@ -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: @@ -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 @@ -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 -