summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpatkarcarasent <143094465+patkarcarasent@users.noreply.github.com>2024-05-02 11:41:52 +0200
committerGitHub <noreply@github.com>2024-05-02 11:41:52 +0200
commitf97e0374fbdaff7cf200ba47858e4e6fc25cda43 (patch)
treec7e5b52875f2cd0ad00cd1b0f71780f7a7518b10
parent320dee1ebeb92b54d5a30208a1fd864b90c8cc28 (diff)
downloadvyos-documentation-f97e0374fbdaff7cf200ba47858e4e6fc25cda43.tar.gz
vyos-documentation-f97e0374fbdaff7cf200ba47858e4e6fc25cda43.zip
Update cloud-init.rst
Added additional documentation regarding the need to use "exec sg vyattacfg" to run script as the correct group, to avoid configuration pitfalls.
-rw-r--r--docs/automation/cloud-init.rst9
1 files changed, 9 insertions, 0 deletions
diff --git a/docs/automation/cloud-init.rst b/docs/automation/cloud-init.rst
index bbc8967c..354abd05 100644
--- a/docs/automation/cloud-init.rst
+++ b/docs/automation/cloud-init.rst
@@ -156,6 +156,12 @@ can execute commands and then configure VyOS in the same script.
The following example sets the hostname based on the instance identifier
obtained from the EC2 metadata service.
+Please observe that the same configuration pitfall described in :ref:`command-scripting`
+exists here when running ``configure`` in any context as without user group
+'vyattacfg' will cause the error message ``Set failed`` to appear.
+We therefor need to wrap it and have the script re-execute itself with the correct
+group permissions.
+
.. code-block:: yaml
@@ -166,6 +172,9 @@ obtained from the EC2 metadata service.
permissions: '0775'
content: |
#!/bin/vbash
+ if [ "$(id -g -n)" != 'vyattacfg' ] ; then
+ exec sg vyattacfg -c "/bin/vbash $(readlink -f $0) $@"
+ fi
source /opt/vyatta/etc/functions/script-template
hostname=`curl -s http://169.254.169.254/latest/meta-data/instance-id`
configure