Commit 3a3d2972 authored by rgaudin's avatar rgaudin
Browse files

Using an offline copy of the YAML catalog in Qemu

- copy parsed YAML_CATALOGS to QEMU (/home/pi/catalog_xxx.yml) during setup step
- using those files via file:// URLs in move-content steps
Qemu stages should now be 100% offline.
parent ecc49d3b
......@@ -7,7 +7,7 @@
- name: Install catalogs
become: yes
become_user: "{{ username }}"
command: ideascube catalog remotes add "{{ item.name }}" "{{ item.description }}" "{{ item.url }}"
command: ideascube catalog remotes add "{{ item.name }}" "{{ item.description }}" "{{ item.local_url }}"
with_items: "{{ ansible_local.config.catalogs }}"
tags: move-content
......
......@@ -6,12 +6,18 @@ import json
import tempfile
import posixpath
import yaml
from data import mirror
from util import ONE_GB
from backend.catalog import CATALOGS
from backend.content import get_content
from backend.catalog import CATALOGS, get_catalogs
ansiblecube_path = "/var/lib/ansible/local"
# update CATALOGS to include our in-qemu local URL
for catalog in CATALOGS:
catalog.update(
{"local_url": "file:///home/pi/catalog_{}.yml".format(catalog["name"])}
)
def run(machine, tags, extra_vars={}, secret_keys=[]):
......@@ -183,6 +189,18 @@ def run_phase_one(machine, extra_vars, secret_keys, logo=None, favicon=None, css
extra_vars.update({"has_custom_branding": has_custom_branding})
# save YAML catalogs into local files inside VM for use by ideascube
for index, catalog in enumerate(CATALOGS):
with tempfile.NamedTemporaryFile(suffix=".yml") as fd:
yaml.safe_dump(
get_catalogs(machine._logger)[index],
fd,
default_flow_style=False,
allow_unicode=True,
encoding="utf-8",
)
machine.put_file(fd.name, catalog["local_url"].replace("file://", ""))
run(machine, tags, extra_vars, secret_keys)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment