Module import mounts of one file in data folder

Hi there,

i’m trying to connect our existing ansible roles into an already existing hugo website. Unfortunately this is all in a corporate environment which makes it difficult to share the code but i guess you’ll quickly understand where i am heading.

An Ansible role has (at least per our convention) a README.md in the main folder and a yaml file with the meta information under “meta/main.yml”. See for example this hugo ansible role. When trying to use that role in my website, i immediately was drawn to the hugo module support, where i would like to use that as follows:

[module]
  [[module.imports]]
    path = "github.com/manala/ansible-role-hugo"
    disabled = false

    [[module.imports.mounts]]
      source = "README.md"
      target = "content/ansible/roles/hugo/hugo.md"

As you can see i’d try to ONLY import the README.md file to make sure that no other files are rendered or copied to the target page (some roles are huge - doesn’t make sense). This configuration is fine so far - everything renders etc.

Then i tried to add a second mount with this configuration into the data folder

[module]
  [[module.imports]]
    path = "github.com/manala/ansible-role-hugo"
    disabled = false

    [[module.imports.mounts]]
      source = "README.md"
      target = "content/ansible/roles/hugo/hugo.md"

    [[module.imports.mounts]]
    source = "meta/main.yml"
    target = "data/ansible/roles/hugo.yml"

which gives me the following error

ERROR 2020/04/03 12:37:22 Add site dependencies: create deps: create PathSpec: build filesystems: this fs supports directories only

Since i didn’t get to a configuration (i e.g. created the required subfolders etc) that worked for the mount of one file into the data folder my question boils down to: Should this be possible? Or will it ever be?

Thanks in advance!

Best Regards, Uli

@bep sorry for pinging you directly - do you maybe have an idea?

bep mentioned a solution in another issue: Hugo Module Mounts: use root file as source

I had the same issue and loaded my file to the assets folder instead as suggested:

[[module.imports.mounts]]
    source=".github/workflows/deploy_prod.yaml"
    target="assets/configs/deploy_prod.yaml"

Then in the shortcode, I load the “asset” through the resources method and apply the transform as suggested by bep

{{ $deployProd := resources.Get "configs/deploy_prod.yaml" | transform.Unmarshal }}