Skip to content

Commit 440a551

Browse files
committed
Merge pull request #9 from fangohr/bug-008
Bug 008
2 parents 8912560 + 7875772 commit 440a551

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

jobs/hook.yml

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,32 @@
4444
path={{ artefact_dir }}/{{ output_box }}
4545
register: box_status
4646

47-
- name: Create box file using vagrant, and include a specific Vagrant file.
48-
command: vagrant package --output {{ artefact_dir }}/{{ output_box }} --vagrantfile ../../guest_resources/vagrantfiles/Vagrantfile_{{ vm_name }}_builtin
47+
# Determine whether or not an inbuilt Vagrantfile is supplied. If it is, we
48+
# package the box with it. Otherwise, we package the box without an in-built
49+
# Vagrantfile.
50+
#
51+
# By the way, "isreg" means "is a regular file?".
52+
53+
- name: Define the path for in-built Vagrantfiles.
54+
set_fact:
55+
inbuilt_vagrantfile_path: "{{ vm_dir }}/../../guest_resources/vagrantfiles"
56+
57+
- name: Determine whether or not a builtin Vagrantfile exists for this target.
58+
stat:
59+
path: "{{ inbuilt_vagrantfile_path }}/Vagrantfile_{{ vm_name }}_builtin"
60+
register: vagrantfile
61+
62+
- name: Create box file using vagrant, and include a built-in Vagrant file if it exists.
63+
command: vagrant package --output {{ artefact_dir }}/{{ output_box }} --vagrantfile {{ inbuilt_vagrantfile_path }}/Vagrantfile_{{ vm_name }}_builtin
64+
chdir={{ vm_dir }}
65+
creates={{ artefact_dir }}/{{ output_box }}
66+
when: vagrantfile.stat.exists and (not box_status.stat.exists or (box_status.stat.isreg and clobber_output))
67+
68+
- name: Create box file using vagrant without a built-in Vagrant file if it is absent.
69+
command: vagrant package --output {{ artefact_dir }}/{{ output_box }}
4970
chdir={{ vm_dir }}
5071
creates={{ artefact_dir }}/{{ output_box }}
51-
when: not box_status.stat.exists or (box_status.stat.isreg and clobber_output)
72+
when: (not vagrantfile.stat.exists) and (not box_status.stat.exists or (box_status.stat.isreg and clobber_output))
5273

5374
- name: Extract the virtual machine disk (VMDK) file from the box.
5475
command: tar -xvf {{ output_box }} -C {{ artefact_dir }} ./box-disk1.vmdk

0 commit comments

Comments
 (0)