Skip to content

Commit 3eb4b08

Browse files
committed
Automate package building
* Split VM into two, one for building and one for testing * Automate building, .deb creation, and installation with Ansible
1 parent 705d051 commit 3eb4b08

File tree

2 files changed

+46
-6
lines changed

2 files changed

+46
-6
lines changed

testing/vagrant/Vagrantfile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@ Vagrant.configure("2") do |config|
44
config.vm.synced_folder '.', disabled: true
55
config.vm.synced_folder '../..', '/vagrant', type: 'rsync', rsync__exclude: ['target', 'testing']
66

7-
config.vm.network "forwarded_port", guest: 2004, host: 2004
8-
97
config.vm.provision "ansible" do |ansible|
108
ansible.playbook = "playbook.yml"
119
end
10+
11+
config.vm.define "building" do |building|
12+
end
13+
14+
config.vm.define "testing" do |testing|
15+
testing.vm.network "forwarded_port", guest: 2004, host: 2004
16+
end
1217
end

testing/vagrant/playbook.yml

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,32 @@
1-
- hosts: all
2-
3-
become: yes
1+
- hosts: building
42

53
tasks:
64
- name: install Rust
75
shell: curl https://sh.rustup.rs -sSf | sh -s -- -y
86
args:
97
creates: /home/vagrant/.cargo/bin/rustc
10-
become: no
118

9+
- name: compile
10+
shell: . ~/.profile && cargo build --release
11+
args:
12+
chdir: /vagrant
13+
14+
- name: strip binary
15+
shell: strip /vagrant/target/release/better-than-basic
16+
17+
- name: grab binary
18+
fetch:
19+
src: /vagrant/target/release/better-than-basic
20+
dest: builds/
21+
22+
- name: build .deb
23+
local_action: command fpm --log info --verbose -t deb -s dir -p builds/better-than-basic_VERSION_ARCH.deb -n better-than-basic -v 0.1.1 --directories /etc/better-than-basic --directories /usr/share/better-than-basic -a x86_64 -m "James Sanderson <[email protected]>" --deb-systemd ../../better-than-basic.service ../../config.toml=/etc/better-than-basic/config.toml ../../users.toml=/etc/better-than-basic/users.toml builds/building/vagrant/target/release/better-than-basic=/usr/sbin/better-than-basic ../../static=/usr/share/better-than-basic ../../templates=/usr/share/better-than-basic
24+
25+
- hosts: testing
26+
27+
become: yes
28+
29+
tasks:
1230
- name: install nginx
1331
package:
1432
name: nginx
@@ -31,6 +49,23 @@
3149
src: private
3250
dest: /var/www/html
3351

52+
- name: upload .deb
53+
copy:
54+
src: builds/better-than-basic_0.1.1_amd64.deb
55+
dest: /root/
56+
57+
- name: uninstall old better-than-basic
58+
package:
59+
name: better-than-basic
60+
state: absent
61+
62+
- name: install better-than-basic
63+
package:
64+
deb: /root/better-than-basic_0.1.1_amd64.deb
65+
66+
- name: check better-than-basic is running
67+
command: service better-than-basic status
68+
3469
handlers:
3570
- name: reload nginx
3671
service: name=nginx state=reloaded

0 commit comments

Comments
 (0)