From eb99835565b25149ff0039ddebce63e040b122c8 Mon Sep 17 00:00:00 2001 From: Lionel Coupouchetty-Ramouchetty Date: Sun, 28 Mar 2021 13:30:39 +0200 Subject: [PATCH] feat: install yunohost on a test vagrant vm --- Vagrantfile | 32 +++++++- integration-tests-playbook.yml | 133 +++++++++++---------------------- 2 files changed, 73 insertions(+), 92 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 8a65c18..b20285f 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -2,12 +2,36 @@ # vi: set ft=ruby : Vagrant.configure("2") do |config| - config.vm.box = "generic/debian10" - config.vm.provision "ansible" do |ansible| - ansible.playbook = "playbook.yml" +end +Vagrant.configure('2') do |config| + + if ARGV[1] == 'test' + ARGV.delete_at(1) + test = true + else + test = false end + + config.vm.box = "generic/debian10" config.vm.provider :libvirt do |libvirt| libvirt.memory = 3072 end - config.vm.synced_folder ".", "/restic_ynh" + if test == false + config.vm.define :check do |check| + check.vm.hostname = 'check' + end + config.vm.provision "ansible" do |ansible| + ansible.playbook = "playbook.yml" + end + config.vm.synced_folder ".", "/restic_ynh" + else + config.vm.define :test do |test| + test.vm.hostname = 'test' + end + config.vm.provision "ansible" do |ansible| + ansible.playbook = "integration-tests-playbook.yml" + end + config.vm.synced_folder ".", "/restic_ynh" + end + end diff --git a/integration-tests-playbook.yml b/integration-tests-playbook.yml index a03ff1b..cbe64ff 100644 --- a/integration-tests-playbook.yml +++ b/integration-tests-playbook.yml @@ -22,96 +22,53 @@ - name: reboot if required reboot: when: _reboot_required_stat.stat.exists -- name: get package checker +- name: install yunohost hosts: all become: true vars: ansible_python_interpreter: python3 + installation_script_path: /tmp/yunohost_installation_script.sh tasks: - - name: install git - apt: - name: git - state: present - - name: clone package checker - git: - repo: 'https://github.com/YunoHost/package_check.git' - dest: /package_check - - name: set vagrant as package check owner - file: - path: /package_check - owner: vagrant - group: vagrant -- name: install package checker requirements - hosts: all - become: true - vars: - ansible_python_interpreter: python3 - tasks: - - name: install test env required apt packages - apt: - name: - - git - - snapd - state: present - - name: install snap core package - community.general.snap: - name: - - core - - name: install snap lxd package - community.general.snap: - name: - - lxd - - name: make vagrant user member of lxd group - user: - name: vagrant - groups: lxd - append: true - - name: add lxc and lxd to /usr/local/bin - file: - dest: /usr/local/bin/{{ item }} - src: /snap/bin/{{ item }} - state: link - loop: - - lxc - - lxd - - name: install test script required apt packages - apt: - name: - - python3-pexpect - - python3-pip - - lynx - - jq - - name: create ansible local facts directory - file: - path: /etc/ansible/facts.d - state: directory - - name: debug local facts - debug: - var: ansible_local - - name: initialize lxd - command: lxd init --auto - notify: - - update local facts - when: > - 'provision' not in ansible_local - or 'lxd' not in ansible_local['provision'] - or 'initialized' not in ansible_local['provision']['lxd'] - or not ansible_local['provision']['lxd']['initialized'] - - name: list lxc remotes - become_user: vagrant - command: lxc remote list - changed_when: "'yunohost' not in _lxc_remote_list.stdout" - register: _lxc_remote_list - notify: - - add lxc yunohost remote - handlers: - - name: update local facts - copy: - dest: /etc/ansible/facts.d/provision.fact - content: | - [lxd] - initialized=true - - name: add lxc yunohost remote - become_user: vagrant - command: lxc remote add yunohost https://devbaseimgs.yunohost.org --public --accept-certificate - changed_when: true + - name: stat /etc/yunohost directory + stat: + path: /etc/yunohost + register: _stat_etc_yunohost + - block: + - name: retrieve ynh installation script + get_url: + url: https://install.yunohost.org + dest: "{{ installation_script_path }}" + mode: +x + owner: root + group: root + - name: install yunohost + command: bash {{ installation_script_path }} -a -f + # -a automatic and -f do not run checks + # I don't know why, after YNH installation, dnsmasq is down... + # dnsmasq.service: Start-post operation timed out. Stopping. + # found a post on YNH forum with no answer: + # https://forum.yunohost.org/t/dnsmasq-fails-to-start-in-post-install-on-fresh-system/10153 + # so I just use a workaround, start the service... + - name: ensure dnsmasq service is started + service: + name: dnsmasq + state: started + - name: install python3-pip + apt: + name: python3-pip + - name: install pexpect + pip: + executable: pip3 + name: pexpect + - name: run post installation + ansible.builtin.expect: + command: yunohost tools postinstall + timeout: null + responses: + (?i)main domain: restic.test + (?i)administration password: This is my password! + - name: remove installation script + file: + path: "{{ installation_script_path }}" + state: absent + when: not _stat_etc_yunohost.stat.exists