1.\" SPDX-License-Identifier: BSD-2-Clause 2.\" 3.\" Copyright (c) 2025 Baptiste Daroussin <bapt@FreeBSD.org> 4.\" Copyright (c) 2025 Jesús Daniel Colmenares Oviedo <dtxdf@FreeBSD.org> 5.\" 6.Dd June 8, 2026 7.Dt NUAGEINIT 7 8.Os 9.Sh NAME 10.Nm nuageinit 11.Nd initialize a cloud-init environment 12.Sh DESCRIPTION 13The 14.Nm 15program is used to initialize instances in a cloud environment. 16.Nm 17runs at the first boot after the system installation. 18It is composed of three 19.Xr rc 8 20scripts: 21.Bl -tag -width "nuageinit" 22.It Cm nuageinit 23This script detects the type of cloud environment and gathers 24the configuration data accordingly. 25The following cloud environments are supported right now: 26.Bl -tag -width "OpenStack" 27.It ondisk 28A cloud agnostic environment where the disk is provided to the system 29with the configuration data on it. 30The disk must be formatted using one of the following filesystems: 31.Xr cd9660 4 32or 33.Xr msdosfs 4 34and be labelled (via filesystem label) either 35.Ar config-2 36or 37.Ar cidata . 38.It OpenStack 39The system is running in an 40.Lk https://www.openstack.org/ OpenStack environment . 41It is detected via the 42.Ar smbios.system.product 43.Xr smbios 4 44description available in 45.Xr kenv 2 . 46.El 47.Pp 48Depending on the cloud environment above, 49.Nm 50will attempt to configure the instance. 51This script executes early 52after all the local filesystem are mounted but before 53the network is configured. 54.It Cm nuageinit_post_net 55This script is responsible for processing the configurations that are network 56dependent: 57.Bl -bullet 58.It 59dealing with packages 60.It 61dealing with users (which can depend on shell provided by packages) 62.El 63.It Cm nuageinit_user_data_script 64This script is responsible for executing everything which would have 65been passed via the configuration to be executed, via the configuration 66or because the user_data provided is a script. 67.El 68.Pp 69The default user for nuageinit is a user named 70.Va freebsd 71with a password set to 72.Va freebsd 73and a login shell set to 74.Va /bin/sh . 75.Sh CONFIGURATION 76The configuration of 77.Nm 78is typically provided as metadata by the cloud provider. 79The metadata is presented to nuageinit in different forms depending on 80the provider: 81.Bl -tag -width "config-2" 82.It nocloud 83If the data is provided via a disk labelled 84.Va cidata , 85then the metadata is provided in the form of a file named 86.Pa meta-data 87in YAML format. 88.Nm 89will configure the hostname of the instance according to the value of the 90following variables 91.Va local-hostname 92or 93.Va hostname . 94.It config-2 95If the data is provided via a disk labelled 96.Va config-2 97or if it is fetched from OpenStack, 98the metadata is expected in two json files: 99.Pp 100The 101.Pa meta_data.json 102file supports the following keys: 103.Bl -tag -width "public_keys" 104.It Ic hostname 105Set the hostname of the instance. 106.It Ic public_keys 107Append each entry of the array to 108.Nm 109default user which will be created. 110.El 111.Pp 112The 113.Pa network_data.json 114file supports the following keys: 115.Bl -tag -width "public_keys" 116.It Ic links 117Array of network interfaces to be configured. 118.It Ic networks 119Array of network configurations to be set. 120.It Ic services 121Array of service configurations to be set (e.g: DNS). 122.El 123.El 124.Pp 125Along with the metadata, a user data file is provided, either named 126.Pa user_data 127or 128.Pa user-data . 129If this file starts with a 130.Qq #! , 131it will be executed at the end of the boot via 132.Cm nuageinit_user_data_script . 133If this file starts with 134.Qq #cloud-config , 135it will be parsed as a YAML configuration file. 136All other cases will be ignored. 137.Pp 138The 139.Qq #cloud-config 140configuration entries supported by 141.Nm : 142.Bl -tag -width "config-2" 143.It Ic fqdn 144Specify a fully qualified domain name for the instance. 145.It Ic hostname 146Specify the hostname of the instance if 147.Qq Ic fqdn 148is not set. 149.It Ic manage_etc_hosts 150Boolean which determines whether the hostname should be added to 151.Pa /etc/hosts 152on the 153.Qq 127.0.0.1 154and 155.Qq ::1 156localhost lines. 157Defaults to 158.Ar true . 159Set to 160.Ar false 161to skip this behaviour. 162.It Ic mounts 163A list of mount points to configure. 164Each entry is written to 165.Pa /etc/fstab 166and the mount point directory is created. 167.Pp 168Each entry can be specified as a list: 169.Bd -literal -offset indent 170[ device, mountpoint, fstype ] 171.Ed 172.Pp 173or as an object: 174.Bd -literal -offset indent 175{ device: "...", mountpoint: "...", type: "...", options: "..." } 176.Ed 177.Pp 178The following keys are recognized: 179.Bl -tag -width "options" 180.It device (or name, spec) 181The device to mount. 182.It mountpoint (or mount_point) 183The mount point directory. 184.It type (or fstype, filesystem) 185The filesystem type. 186.It options (or opts) 187The mount options, defaults to 188.Qq rw . 189.It dump 190The dump frequency for 191.Xr dump 8 , 192defaults to 0. 193.It passno 194The pass number for 195.Xr fsck 8 , 196defaults to 0. 197.El 198.It Ic resolv_conf 199An object configuring the content of 200.Pa /etc/resolv.conf . 201.Pp 202The following keys are recognized: 203.Bl -tag -width "nameservers" 204.It nameservers 205A list of IP addresses for DNS name servers. 206.It searchdomains 207A list of search domains. 208.It domain 209A single domain name. 210.It sortlist 211A list of IP/netmask sortlist entries. 212.It options 213A dictionary of resolver options. 214.El 215.It Ic locale 216Set the system locale by appending 217.Qq Cm export 218statements to 219.Pa /etc/profile . 220.Pp 221If the value is a string, it is used as the 222.Dq Cm LANG 223value. 224If the value is an object mapping, each key-value pair is exported. 225.It Ic keyboard 226An object configuring the keyboard layout. 227.Pp 228Sets the 229.Va keymap 230variable in 231.Pa /etc/rc.conf.d/keymap . 232.Pp 233The following keys are recognized: 234.Bl -tag -width "variant" 235.It layout 236The keyboard layout (e.g., 237.Qq fr , 238.Qq de , 239.Qq us ) . 240.It variant 241The keyboard variant (e.g., 242.Qq acc , 243.Qq nodeadkeys ) . 244.El 245.It Ic ssh_authkey_fingerprints 246Boolean which determines whether fingerprints of SSH host keys 247should be logged to the console. 248Defaults to 249.Ar false . 250.It Ic ntp 251An object configuring the NTP daemon by writing 252.Pa /etc/ntp.conf . 253.Pp 254The following keys are recognized: 255.Bl -tag -width "enabled" 256.It servers 257A list of NTP server addresses. 258.It pools 259A list of NTP pool addresses. 260.It enabled 261Boolean, defaults to 262.Ar true . 263Set to 264.Ar false 265to skip NTP configuration. 266.El 267.Pp 268Alternatively, 269.Ic ntp 270can be a list of server addresses (legacy format). 271.It Ic ca_certs 272An object managing CA certificates. 273.Pp 274The following keys are recognized: 275.Bl -tag -width "remove_defaults" 276.It trusted 277A list of PEM-encoded CA certificates to add to the system trust store. 278Certificates are written to 279.Pa /usr/share/certs/trusted/ 280and 281.Xr certctl 8 282rehash is executed. 283.It remove_defaults 284Boolean, if 285.Ar true , 286remove the default CA certificates. 287.El 288.It Ic timezone 289Sets the system timezone based on the value provided. 290.Pp 291See also 292.Xr tzfile 5 . 293.It Ic groups 294An array of strings or objects to be created: 295.Bl -bullet 296.It 297If the entry is a string, 298a group using this string as a name will be created. 299.It 300if the entry is an object, the 301.Qq Ar key 302will be used as the name of the group, the 303.Qq Ar value 304is expected to be a list of members (array), specified by name. 305.El 306.It Ic ssh_deletekeys 307Boolean which determines if the existing SSH host keys in 308.Pa /etc/ssh 309should be removed on first boot. 310New host keys will be generated automatically by 311.Xr sshd 8 . 312.It Ic ssh_keys 313An object of multiple key/values, 314.Qq Cm keys 315being in the form 316.Ar algo_private 317or 318.Ar algo_public , 319.Qq Cm values 320being the actual content of the files in 321.Pa /etc/ssh . 322.It Ic ssh_authorized_keys 323Append each entry of the array to 324.Nm 325default user which will be created. 326.It Ic allow_public_ssh_keys 327Boolean which determines if the public SSH keys from the datasource 328metadata are imported to the default user and root. 329If set to 330.Ar false , 331only the keys specified in 332.Ic ssh_authorized_keys 333are used. 334Defaults to 335.Ar true . 336.It Ic ssh_pwauth 337boolean which determines the value of the 338.Qq Ic PasswordAuthentication 339configuration in 340.Pa /etc/ssh/sshd_config 341.It Ic disable_root 342Boolean which determines if root login via SSH should be disabled. 343If set to 344.Ar true 345.Pq the default , 346the public SSH keys are written to 347.Pa /root/.ssh/authorized_keys 348with the options specified in 349.Ic disable_root_opts , 350which by default redirects the login to the default user. 351If set to 352.Ar false , 353the public SSH keys are written to 354.Pa /root/.ssh/authorized_keys 355without any restriction. 356.It Ic disable_root_opts 357String or array of options used to prefix the public SSH keys in 358.Pa /root/.ssh/authorized_keys 359when 360.Ic disable_root 361is set to 362.Ar true . 363The 364.Ar $USER 365and 366.Ar $DISABLE_USER 367placeholders are replaced with the default user name and 368.Ar root 369respectively. 370If not specified, defaults to 371.Ar no-port-forwarding,no-agent-forwarding,no-X11-forwarding,command="echo 'Please login as the user "$USER" rather than the user "$DISABLE_USER".';echo;sleep 10;exit 142" . 372.Pp 373Only the first value is used when an array is provided. 374.It Ic network 375Network configuration parameters. 376.Pp 377Specifying the following parameters from a file named 378.Pa network-config 379takes precedence over their specification from the 380.Ic network 381parameter of 382.Pa user-data . 383.Bl -tag -width "ethernets" 384.It Ic ethernets 385Mapping representing a generic configuration for existing network interfaces. 386.Pp 387Each key is an interface name that is only used when no 388.Sy match 389rule is specified. 390If 391.Sy match 392rules are specified, an arbitrary name can be used 393.Po e.g.: id0 Pc . 394.Bl -tag -width "nameservers" 395.It Ic match 396This selects a subset of available physical devices by various hardware 397properties. 398The following configuration will then apply to all matching devices, as soon as 399they appear. 400All specified properties must match. 401The following properties for 402creating matches are supported: 403.Bl -tag -width "macaddress" 404.It Ic macaddress 405.No Device's MAC address in the form Sy xx:xx:xx:xx:xx:xx . 406Letters should be lowercase. 407.It Ic name 408Current interface name. 409Lua pattern-matching expressions are supported. 410.It Ic driver 411Interface driver name and unit number of the interface. 412Lua pattern-natching expressions 413are supported. 414.El 415.It Ic set-name 416When matching on unique properties such as MAC, match rules can be written so 417that they match only one device. 418Then this property can be used to give that device a more 419specific/desirable/nicer name than the default. 420.Pp 421While multiple properties can be used in a match, 422.Sy macaddress 423is required for nuageinit to perform the rename. 424.It Ic mtu 425The MTU key represents a device's Maximum Transmission Unit, the largest size 426packet or frame. 427.It Ic wakeonlan 428Enable wake on LAN. 429Off by default. 430.It Ic dhcp4 431Configure the interface to use DHCP. 432.Pp 433This takes precedence over 434.Sy addresses 435when both are specified. 436.It Ic addresses 437List of strings representing IPv4 or IPv6 addresses. 438.It Ic gateway4 439Set default gateway for IPv4, for manual address configuration. 440This requires setting 441.Sy addresses 442too. 443.Pp 444Since only one default router can be configured at a time, this parameter is 445applied when processing the first entry, and any others are silently ignored. 446.It Ic gateway6 447Set default gateway for IPv6, for manual address configuration. 448This requires setting 449.Sy addresses 450too. 451.Pp 452Since only one default router can be configured at a time, this parameter is 453applied when processing the first entry, and any others are silently ignored. 454.It Ic nameservers 455Set DNS servers and search domains, for manual address configuration. 456.Pp 457There are two supported fields: 458.Bl -tag -width "addresses" 459.It Ic search 460Search list for host-name lookup. 461.It Ic addresses 462List of IPv4 or IPv6 name server addresses that the resolver should query. 463.El 464.El 465.El 466.It Ic runcmd 467An array of commands to be run at the end of the boot process 468.It Ic packages 469List of packages to be installed. 470.It Ic package_update 471Update the remote package metadata. 472.It Ic package_upgrade 473Upgrade the packages installed to their latest version. 474.It Ic power_state 475An object controlling the power state of the instance after configuration. 476The following keys are recognized: 477.Bl -tag -width "condition" 478.It Ic delay 479Time to wait before the action. 480Can be 481.Qq now 482or a time accepted by 483.Xr shutdown 8 484(e.g., 485.Qq +5 486for five minutes). 487Defaults to 488.Qq now . 489.It Ic mode 490The action to take: 491.Qq poweroff , 492.Qq reboot , 493or 494.Qq halt . 495Defaults to 496.Qq poweroff . 497.It Ic message 498Optional message to display to users. 499.It Ic timeout 500Not supported on 501.Fx , 502silently ignored. 503.It Ic condition 504Boolean or command string. 505If 506.Qq false , 507the action is skipped. 508If a string, it is run as a command; the action is only taken if the command 509succeeds. 510Defaults to 511.Qq true . 512.El 513.It Ic phone_home 514An object configuring the posting of instance data to a URL. 515.Pp 516The following keys are recognized: 517.Bl -tag -width "tries" 518.It Ic url 519The target URL to which the data will be posted. 520.It Ic post 521A list of data items to send, or the string 522.Qq all 523to send all supported items. 524Supported items are: 525.Qq hostname , 526.Qq fqdn , 527.Qq instance_id , 528.Qq pub_key_rsa , 529.Qq pub_key_ecdsa , 530and 531.Qq pub_key_ed25519 . 532.It Ic tries 533Number of retry attempts. 534Defaults to 1. 535.El 536.Pp 537The data is posted using 538.Xr fetch 1 . 539.It Ic final_message 540A string message to be displayed at the end of the boot process. 541The placeholder 542.Qq $UPTIME 543is replaced with the system uptime in seconds. 544.It Ic users 545Specify a list of users to be created: 546.Bl -tag -width "ssh_authorized_keys" 547.It Ic name 548Name of the user. 549.It Ic gecos 550GECOS for the user. 551.It Ic homedir 552The path of the home directory for the user. 553.It Ic primary_group 554The main group the user should belong to. 555.It Ic groups 556The list of other groups the user should belong to. 557.It Ic no_create_home 558A boolean which determines if the home directory should be created or not. 559.It Ic shell 560The shell that should be used for the user. 561.It Ic ssh_authorized_keys 562List of SSH keys for the user. 563.It Ic passwd 564The encrypted password for the user. 565.It Ic plain_text_passwd 566The password in plain text for the user. 567Ignored if an encrypted password is already provided. 568.It Ic lock_passwd 569Boolean to determine if the user account should be locked. 570The legacy 571.Ic locked 572key is also accepted. 573.It Ic sudo 574A string or an array of strings which should be appended to 575.Pa ${LOCALBASE}/etc/sudoers.d/90-nuageinit-users 576.It Ic doas 577A string or an array of strings which should be appended to 578.Pa ${LOCALBASE}/etc/doas.conf 579.Pp 580Instead of hardcoding the username, you can use 581.Sy %u , 582which will be replaced by the current username. 583.El 584.Pp 585A special case exist: if the entry is a simple string with the value 586.Qq default , 587then the default user is created. 588Configuring 589.Nm sudo 590or 591.Nm doas 592does not automatically install them. 593Ensure the relevant command is listed in your 594.Nm packages 595section. 596.It Ic bootcmd 597An array of commands to be run early in the boot process, 598before the hostname is set and before the network is configured. 599.It Ic chpasswd 600Change the passwords for users, it accepts the following keys: 601.Bl -tag -width "expire" 602.It Ic expire 603Boolean to force the user to change their password on first login. 604.It Ic users 605An array of objects: 606.Bl -tag -width "password" 607.It Ic name 608Specify the user whose password will be changed. 609.It Ic password 610Specify a text line with the new password or 611.Qq Cm RANDOM 612to assign the password randomly. 613If the textline starts with 614.Qq Cm $x$ 615where x is a number, then the password is considered encrypted, 616otherwise the password is considered plaintext. 617.El 618.El 619.It Ic write_files 620An array of objects representing files to be created at first boot. 621The files are being created before the installation of any packages 622and the creation of the users. 623The only mandatory field is: 624.Ic path . 625It accepts the following keys for each objects: 626.Bl -tag -width "permissions" 627.It Ic content 628The content to be written to the file. 629If this key is not existing then an empty file will be created. 630.It Ic encoding 631Specify the encoding used for content. 632If not specified, then plain text is considered. 633Only 634.Ar b64 635and 636.Ar base64 637are supported for now. 638.It Ic path 639The path of the file to be created. 640.Pq Note intermerdiary directories will be created . 641.It Ic permissions 642A string representing the permission of the file in octal. 643.It Ic owner 644A string representing the owner, two forms are possible: 645.Ar user 646or 647.Ar user:group . 648.It Ic append 649A boolean to specify the content should be appended to the file if the file 650exists. 651.It Ic defer 652A boolean to specify that the files should be created after the packages are 653installed and the users are created. 654.El 655.El 656.Pp 657Additionally, user-data can be provided as a MIME multipart message 658with content type 659.Qq multipart/mixed . 660Each part is handled according to its 661.Qq Content-Type 662header. 663Supported part types: 664.Bl -tag -width "text/x-shellscript" 665.It text/cloud-config 666Processed as a cloud-config YAML document. 667.It text/x-shellscript 668Saved as an executable script for later execution. 669.El 670.Sh EXAMPLES 671Here is an example of a YAML configuration for 672.Nm : 673.Bd -literal 674#cloud-config 675bootcmd: 676 - kldload if_bridge 677fqdn: myhost.mynetwork.tld 678users: 679 - default 680 - name: user 681 gecos: Foo B. Bar 682 sudo: ALL=(ALL) NOPASSWD:ALL 683 ssh_authorized_keys: 684 - ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAr... 685packages: 686 - neovim 687 - git-lite 688 - sudo 689package_update: true 690package_upgrade: true 691runcmd: 692 - logger -t nuageinit "boot finished" 693ssh_deletekeys: true 694disable_root: true 695ssh_keys: 696 ed25519_private: | 697 -----BEGIN OPENSSH PRIVATE KEY----- 698 blabla 699 ... 700 -----END OPENSSH PRIVATE KEY----- 701 ed25519_public: ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIK+MH4E8KO32N5CXRvXVqvyZVl0+6ue4DobdhU0FqFd+ 702network: 703 ethernets: 704 vtnet0: 705 addresses: 706 - 192.168.8.2/24 707 gateway4: 192.168.8.1 708.Ed 709.Sh SEE ALSO 710.Xr kenv 2 , 711.Xr cd9660 4 , 712.Xr msdosfs 4 , 713.Xr smbios 4 , 714.Xr ssh_config 5 , 715.Xr rc 8 716.Sh STANDARDS 717.Nm 718is believed to conform to the 719.Lk https://cloud-init.io/ Cloud Init 720specification. 721.Sh HISTORY 722.Nm 723appeared in 724.Fx 14.1 725