CLI DHCP Snippet Management

This is a list of DHCP snippet management tasks to perform with the MAAS CLI. See MAAS CLI on how to get started.

See DHCP for an overview of DHCP snippets.

Create a snippet

When a snippet is created, it is enabled by default.

To create a global snippet:

maas $PROFILE dhcpsnippets create name=$DHCP_SNIPPET_NAME \
    value=$DHCP_CONFIG description=$DHCP_SNIPPET_DESCRIPTION \
    global_snippet=true

To create a subnet snippet:

maas $PROFILE dhcpsnippets create name=$DHCP_SNIPPET_NAME \
    value=$DHCP_CONFIG description=$DHCP_SNIPPET_DESCRIPTION \
    subnet=$SUBNET_ID

A subnet given in CIDR format can also be used in place of the subnet ID.

To create a node snippet:

maas $PROFILE dhcpsnippets create name=$DHCP_SNIPPET_NAME \
    value=$DHCP_CONFIG description=$DHCP_SNIPPET_DESCRIPTION \
    node=$NODE_ID

A hostname can also be used in place of the node ID.

List snippets

To list all snippets (and their characteristics) in the MAAS:

maas $PROFILE dhcpsnippets read

To list a specific snippet:

maas $PROFILE dhcpsnippet read id=$DHCP_SNIPPET_ID

The snippet name can also be used instead of its ID:

maas $PROFILE dhcpsnippet read name=$DHCP_SNIPPET_NAME

Update a snippet

Update a snippet attribute:

maas $PROFILE dhcpsnippet update $DHCP_SNIPPET_ID <option=value>

The snippet name can also be used in place of its ID.

Enable or disable a snippet

Enabling and disabling a snippet is considered a snippet update and is done via a boolean option ('true' or 'false'). This is how a snippet is disabled:

maas $PROFILE dhcpsnippet update $DHCP_SNIPPET_ID enabled=false

The disabling of a snippet removes the text that was added to the dhcpd.conf file when it was created/enabled.

Delete a snippet

To delete a snippet:

maas $PROFILE dhcpsnippet delete $DHCP_SNIPPET_ID

The snippet name can also be used in place of its ID.

© 2018 Canonical Ltd. Ubuntu and Canonical are registered trademarks of Canonical Ltd.