mirror of
https://github.com/YunoHost-Apps/restic_ynh.git
synced 2024-09-03 20:16:22 +02:00
feat: install yunohost on a test vagrant vm
This commit is contained in:
parent
24f87f8212
commit
eb99835565
2 changed files with 73 additions and 92 deletions
32
Vagrantfile
vendored
32
Vagrantfile
vendored
|
@ -2,12 +2,36 @@
|
||||||
# vi: set ft=ruby :
|
# vi: set ft=ruby :
|
||||||
|
|
||||||
Vagrant.configure("2") do |config|
|
Vagrant.configure("2") do |config|
|
||||||
config.vm.box = "generic/debian10"
|
end
|
||||||
config.vm.provision "ansible" do |ansible|
|
Vagrant.configure('2') do |config|
|
||||||
ansible.playbook = "playbook.yml"
|
|
||||||
|
if ARGV[1] == 'test'
|
||||||
|
ARGV.delete_at(1)
|
||||||
|
test = true
|
||||||
|
else
|
||||||
|
test = false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
config.vm.box = "generic/debian10"
|
||||||
config.vm.provider :libvirt do |libvirt|
|
config.vm.provider :libvirt do |libvirt|
|
||||||
libvirt.memory = 3072
|
libvirt.memory = 3072
|
||||||
end
|
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
|
end
|
||||||
|
|
|
@ -22,96 +22,53 @@
|
||||||
- name: reboot if required
|
- name: reboot if required
|
||||||
reboot:
|
reboot:
|
||||||
when: _reboot_required_stat.stat.exists
|
when: _reboot_required_stat.stat.exists
|
||||||
- name: get package checker
|
- name: install yunohost
|
||||||
hosts: all
|
hosts: all
|
||||||
become: true
|
become: true
|
||||||
vars:
|
vars:
|
||||||
ansible_python_interpreter: python3
|
ansible_python_interpreter: python3
|
||||||
|
installation_script_path: /tmp/yunohost_installation_script.sh
|
||||||
tasks:
|
tasks:
|
||||||
- name: install git
|
- name: stat /etc/yunohost directory
|
||||||
apt:
|
stat:
|
||||||
name: git
|
path: /etc/yunohost
|
||||||
state: present
|
register: _stat_etc_yunohost
|
||||||
- name: clone package checker
|
- block:
|
||||||
git:
|
- name: retrieve ynh installation script
|
||||||
repo: 'https://github.com/YunoHost/package_check.git'
|
get_url:
|
||||||
dest: /package_check
|
url: https://install.yunohost.org
|
||||||
- name: set vagrant as package check owner
|
dest: "{{ installation_script_path }}"
|
||||||
file:
|
mode: +x
|
||||||
path: /package_check
|
owner: root
|
||||||
owner: vagrant
|
group: root
|
||||||
group: vagrant
|
- name: install yunohost
|
||||||
- name: install package checker requirements
|
command: bash {{ installation_script_path }} -a -f
|
||||||
hosts: all
|
# -a automatic and -f do not run checks
|
||||||
become: true
|
# I don't know why, after YNH installation, dnsmasq is down...
|
||||||
vars:
|
# dnsmasq.service: Start-post operation timed out. Stopping.
|
||||||
ansible_python_interpreter: python3
|
# found a post on YNH forum with no answer:
|
||||||
tasks:
|
# https://forum.yunohost.org/t/dnsmasq-fails-to-start-in-post-install-on-fresh-system/10153
|
||||||
- name: install test env required apt packages
|
# so I just use a workaround, start the service...
|
||||||
apt:
|
- name: ensure dnsmasq service is started
|
||||||
name:
|
service:
|
||||||
- git
|
name: dnsmasq
|
||||||
- snapd
|
state: started
|
||||||
state: present
|
- name: install python3-pip
|
||||||
- name: install snap core package
|
apt:
|
||||||
community.general.snap:
|
name: python3-pip
|
||||||
name:
|
- name: install pexpect
|
||||||
- core
|
pip:
|
||||||
- name: install snap lxd package
|
executable: pip3
|
||||||
community.general.snap:
|
name: pexpect
|
||||||
name:
|
- name: run post installation
|
||||||
- lxd
|
ansible.builtin.expect:
|
||||||
- name: make vagrant user member of lxd group
|
command: yunohost tools postinstall
|
||||||
user:
|
timeout: null
|
||||||
name: vagrant
|
responses:
|
||||||
groups: lxd
|
(?i)main domain: restic.test
|
||||||
append: true
|
(?i)administration password: This is my password!
|
||||||
- name: add lxc and lxd to /usr/local/bin
|
- name: remove installation script
|
||||||
file:
|
file:
|
||||||
dest: /usr/local/bin/{{ item }}
|
path: "{{ installation_script_path }}"
|
||||||
src: /snap/bin/{{ item }}
|
state: absent
|
||||||
state: link
|
when: not _stat_etc_yunohost.stat.exists
|
||||||
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
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue