How to create folder `/config/auth/wireguard` with ansible on vyos?

with ansible playbook as show:

     - name: Create a directory `/config/auth/wireguard` if it does not exist
         path: /config/auth/wireguard
         state: directory

After run the playbook, I got error return:

 fatal: [my-vyos]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "_diff_peek": null,
            "_original_basename": null,
            "access_time": null,
            "access_time_format": "%Y%m%d%H%M.%S",
            "attributes": null,
            "follow": true,
            "force": false,
            "group": null,
            "mode": null,
            "modification_time": null,
            "modification_time_format": "%Y%m%d%H%M.%S",
            "owner": null,
            "path": "/config/auth/wireguard",
            "recurse": false,
            "selevel": null,
            "serole": null,
            "setype": null,
            "seuser": null,
            "src": null,
            "state": "directory",
            "unsafe_writes": false
    "msg": "There was an issue creating /config as requested: [Errno 30] Read-only file system: b'/config'",
    "path": "/config/auth/wireguard"

this issue is related to permission , this Ansible’s module should be able to use sudo to create the directory.

another option is using generate wireguard default-keypair on VyOS , it’ll create the directory an keys.

I found a way to solve the problem. FIrstly generate the private_key and publick_key. then treat vyos as a linux with ansible to create a folder and write keys to files on Vyos.
Then I can directly write the vyos configuration to specify the key name.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.