From 37fa83deecb4121ee9a354c08a5addea65f240bf Mon Sep 17 00:00:00 2001 From: Jeff Loughridge Date: Thu, 8 Apr 2021 21:07:33 +0000 Subject: Add initial cloud-init documentation --- docs/automation/cloud-init.rst | 64 ++++++++++++++++++++++++++++++++++++++++++ docs/automation/index.rst | 3 +- 2 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 docs/automation/cloud-init.rst (limited to 'docs') diff --git a/docs/automation/cloud-init.rst b/docs/automation/cloud-init.rst new file mode 100644 index 00000000..f59c1a7b --- /dev/null +++ b/docs/automation/cloud-init.rst @@ -0,0 +1,64 @@ +.. _cloud-init: + +############### +VyOS cloud-init +############### + +Cloud instances of VyOS are initialized using the industry-standard cloud-init. +Via cloud-init, users can execute shell commands and configure the router. + +The initialization is guided by a set of instructions--known as user +data--provided by the user at launch time. VyOS implements a user-data +format called cloud-config. + +Major cloud providers offer a means of providing user-data at the time +of instance launch. Typically the user includes user-data as plain +text and the cloud provider's platform base64 encodes the user-data +before injecting it into the instance. + + +************************ +cloud-config file format +************************ + + +A cloud-config document is written in YAML. The file must begin +with "#cloud-config". The key used to designate a VyOS configuration +is "vyos_config_commands". What follows is VyOS configuration using +the "set-style" syntax. + +Commands requirements: + +* one command per line +* if command ends in a value, it must be inside single quotes +* a single-quote symbol is not allowed inside command or value + + +The commands list produced by the `show configuration commands` command on a +VyOS router should comply with all the requirements, so it is easy to get a +proper commands list by copying it from another router. + +The configuration specified in the cloud-config document is merged with +the default configuration and saved to /config/config.boot. + +Here is an example cloud-config. + +.. code-block:: yaml + + #cloud-config + vyos_config_commands: + - set system host-name 'vyos-prod-ashburn' + - set system ntp server 1.pool.ntp.org + - set system ntp server 2.pool.ntp.org + +*************** +Troubleshooting +*************** + +If you encounter problems, verify that the cloud-config document contains +valid YAML. Online resources such as https://yamlvalidator.com/ provide +a simple tool for validating YAML. + +cloud-init logs to /var/log/cloud-init.log. This file can be helpful in +determining why the configuration varies from what you expect. + diff --git a/docs/automation/index.rst b/docs/automation/index.rst index 935748d0..044505b9 100644 --- a/docs/automation/index.rst +++ b/docs/automation/index.rst @@ -12,4 +12,5 @@ VyOS Automation vyos-api vyos-ansible - command-scripting \ No newline at end of file + command-scripting + cloud-init -- cgit v1.2.3 From 7f481a08a4f812169bd4921a029df3728eff5c64 Mon Sep 17 00:00:00 2001 From: Jeff Loughridge Date: Mon, 12 Apr 2021 13:59:54 +0000 Subject: Enhance cloud-init documentation --- docs/automation/cloud-init.rst | 48 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 5 deletions(-) (limited to 'docs') diff --git a/docs/automation/cloud-init.rst b/docs/automation/cloud-init.rst index f59c1a7b..761a96e3 100644 --- a/docs/automation/cloud-init.rst +++ b/docs/automation/cloud-init.rst @@ -5,17 +5,38 @@ VyOS cloud-init ############### Cloud instances of VyOS are initialized using the industry-standard cloud-init. -Via cloud-init, users can execute shell commands and configure the router. +Via cloud-init, the system performs tasks such as injecting SSH keys and +configuring the network. In addition, the user can supply a custom +configuration at the time of instance launch. -The initialization is guided by a set of instructions--known as user -data--provided by the user at launch time. VyOS implements a user-data -format called cloud-config. +************** +Config Sources +************** + +VyOS support three type of config sources. + +.. stop_vyoslinter + +* Metadata - Metadata is sourced by the cloud platform or hypervisor. In some clouds, there is implemented as an HTTP endpoint at http://169.254.169.254. + +* Network configuration - Ths config source informs the system about the network. + +* User-data - User-data is specified by the user. This config source offers the most flexibility and will be the focus of this documentation. + +.. start_vyoslinter + + +********* +User-data +********* Major cloud providers offer a means of providing user-data at the time of instance launch. Typically the user includes user-data as plain text and the cloud provider's platform base64 encodes the user-data before injecting it into the instance. +VyOS implements a user-data format called cloud-config. + ************************ cloud-config file format @@ -25,7 +46,7 @@ cloud-config file format A cloud-config document is written in YAML. The file must begin with "#cloud-config". The key used to designate a VyOS configuration is "vyos_config_commands". What follows is VyOS configuration using -the "set-style" syntax. +the "set-style" syntax. Both "set" and "delete" commands are supported. Commands requirements: @@ -50,6 +71,23 @@ Here is an example cloud-config. - set system host-name 'vyos-prod-ashburn' - set system ntp server 1.pool.ntp.org - set system ntp server 2.pool.ntp.org + - delete interfaces ethernet eth1 address 'dhcp' + - set interfaces ethernet eth1 address '172.31.7.247/20' + - set protocols static route '172.31.0.0/16' next-hop '100.64.16.1' + +************************* +System Defaults/Fallbacks +************************* + +These are the VyOS defaults and fallbacks. + +* SSH is configured on port 22 +* vyos/vyos credentials if no SSH public key exists in metadata +* DHCP on first Ethernet interface if no network configuration is provided + + +All of these can be overridden using configuration in user-data. + *************** Troubleshooting -- cgit v1.2.3 From 9d2f16ab7309779065f123579542beae9d1247e6 Mon Sep 17 00:00:00 2001 From: Jeff Loughridge Date: Mon, 12 Apr 2021 16:09:30 +0000 Subject: Fix default credentials statement --- docs/automation/cloud-init.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/automation/cloud-init.rst b/docs/automation/cloud-init.rst index 761a96e3..be585321 100644 --- a/docs/automation/cloud-init.rst +++ b/docs/automation/cloud-init.rst @@ -82,7 +82,7 @@ System Defaults/Fallbacks These are the VyOS defaults and fallbacks. * SSH is configured on port 22 -* vyos/vyos credentials if no SSH public key exists in metadata +* vyos/vyos credentials if no others specified by data source * DHCP on first Ethernet interface if no network configuration is provided -- cgit v1.2.3