Browse Source

Add a VagrantFile for testing

tags/1.0.0
Victor Laborie 1 year ago
parent
commit
24cc53521f
4 changed files with 94 additions and 0 deletions
  1. 1
    0
      .gitignore
  2. 40
    0
      Vagrantfile
  3. 48
    0
      test/ansible/evoadmin-mail.yml
  4. 5
    0
      test/ansible/requirements.yml

+ 1
- 0
.gitignore View File

@@ -1,2 +1,3 @@
1 1
 *.swp
2 2
 config/config.ini
3
+.vagrant

+ 40
- 0
Vagrantfile View File

@@ -0,0 +1,40 @@
1
+# -*- mode: ruby -*-
2
+# vi: set ft=ruby :
3
+
4
+Vagrant::DEFAULT_SERVER_URL.replace('https://vagrantcloud.com')
5
+
6
+# Load ~/.VagrantFile if exist, permit local config provider
7
+vagrantfile = File.join("#{Dir.home}", '.VagrantFile')
8
+load File.expand_path(vagrantfile) if File.exists?(vagrantfile)
9
+
10
+Vagrant.configure('2') do |config|
11
+  config.vm.synced_folder "./", "/vagrant", type: "rsync", rsync__exclude: [ '.vagrant', '.git', 'config/config.ini' ]
12
+
13
+  config.vm.network "forwarded_port", guest: 80, host: 8080, auto_correct: true
14
+  config.vm.network "forwarded_port", guest: 443, host: 8443, auto_correct: true
15
+
16
+  $deps = <<SCRIPT
17
+DEBIAN_FRONTEND=noninteractive apt-get -yq install ansible git
18
+ansible-galaxy install -r /vagrant/test/ansible/requirements.yml
19
+echo "[defaults]" > '/vagrant/test/ansible/ansible.cfg'
20
+echo "roles_path = /etc/ansible/roles/evolix" >> '/vagrant/test/ansible/ansible.cfg'
21
+> /etc/hosts
22
+SCRIPT
23
+
24
+  config.vm.define :packmail do |node|
25
+    node.vm.hostname = "evoadmin-mail"
26
+    node.vm.box = "debian/stretch64"
27
+
28
+    node.vm.provision "deps", type: "shell", :inline => $deps
29
+    node.vm.provision "ansible", type: "ansible_local" do |ansible|
30
+      ansible.provisioning_path = "/vagrant/test/ansible"
31
+      ansible.playbook = "evoadmin-mail.yml"
32
+      ansible.install_mode = ":default"
33
+      ansible.raw_arguments = [
34
+        "--become"
35
+      ]
36
+    end
37
+
38
+  end
39
+
40
+end

+ 48
- 0
test/ansible/evoadmin-mail.yml View File

@@ -0,0 +1,48 @@
1
+---
2
+- hosts: all
3
+  gather_facts: yes
4
+  become: yes
5
+
6
+  vars:
7
+    evolinux_hostname: "evoadmin-mail"
8
+    evolinux_domain: "example.com"
9
+    evolinux_fqdn: "{{ evolinux_hostname }}.{{ evolinux_domain }}"
10
+    evomaintenance_alert_email: "evomaintenance-{{ evolinux_hostname }}@example.com"
11
+
12
+  roles:
13
+    - evolinux-base
14
+    - { role: postfix, postfix_packmail: True, postfix_force_main_cf: True }
15
+    - apache
16
+    - { role: php, php_apache_enable: True }
17
+    - { role: webapps/evoadmin-mail }
18
+
19
+  tasks:
20
+  - name: Disable redirection for evoadminmail vhost
21
+    lineinfile:
22
+      dest: /etc/apache2/sites-enabled/evoadminmail.conf
23
+      regexp: "Rewrite"
24
+      state: absent
25
+
26
+  - name: Fix rights on /etc/evolinux
27
+    file:
28
+      dest: /etc/evolinux
29
+      state: directory
30
+      mode: "0711"
31
+
32
+  - name: Link config.ini to evoadmin-mail.ini
33
+    file:
34
+      src: /etc/evolinux/evoadmin-mail.ini
35
+      dest: /vagrant/config/config.ini
36
+      state: link
37
+
38
+  - name: Remove distant htdocs dir
39
+    file:
40
+      dest: /home/evoadmin-mail/www
41
+      state: absent
42
+
43
+  - name: Use local htdocs dir
44
+    file:
45
+      src: /vagrant
46
+      dest: /home/evoadmin-mail/www
47
+      state: link
48
+      force: yes

+ 5
- 0
test/ansible/requirements.yml View File

@@ -0,0 +1,5 @@
1
+---
2
+- name: evolix
3
+  src: https://forge.evolix.org/ansible-roles.git
4
+  scm: git
5
+  version: evoadmin-mail

Loading…
Cancel
Save