diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..8a65c18 --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,13 @@ +# -*- mode: ruby -*- +# 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 + config.vm.provider :libvirt do |libvirt| + libvirt.memory = 3072 + end + config.vm.synced_folder ".", "/restic_ynh" +end diff --git a/playbook.yml b/playbook.yml new file mode 100644 index 0000000..9f29ec4 --- /dev/null +++ b/playbook.yml @@ -0,0 +1,131 @@ +--- +- name: upgrade + hosts: all + become: true + vars: + ansible_python_interpreter: python3 + tasks: + - name: upgrade + apt: + upgrade: true + update_cache: true + - name: stat reboot-required file + stat: + path: /var/run/reboot-required + register: _reboot_required_stat + - name: debug _reboot_required_stat + debug: + var: _reboot_required_stat + - name: reboot if required + reboot: + when: _reboot_required_stat.stat.exists +- name: get package checker + hosts: all + become: true + vars: + ansible_python_interpreter: python3 + 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 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 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 + expect: + command: lxd init + responses: + (?i)Would you like to use LXD clustering: no + (?i)Do you want to configure a new storage pool: yes + (?i)Name of the new storage pool: default + (?i)Name of the storage backend to use: btrfs + (?i)Create a new BTRFS pool: yes + (?i)Would you like to use an existing empty block device: no + (?i)Size in GB of the new loop device: 24GB + (?i)Would you like to connect to a MAAS server: no + (?i)Would you like to create a new local network bridge: yes + (?i)What should the new bridge be called: lxdbr0 + (?i)What IPv4 address should be used: auto + (?i)What IPv6 address should be used: auto + (?i)Would you like the LXD server to be available over the network: no + (?i)Would you like stale cached images to be updated automatically: yes + (?i)preseed to be printed: no + 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