Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changes/issue-841.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!-- markdownlint-disable-file MD013 MD041 -->
FEATURES:

* add `junos_apply_group` resource (Partial fix [#841](https://github.com/jeremmfr/terraform-provider-junos/issues/841))

* add `junos_apply_group_except` resource

* add `junos_group_raw` resource (Partial fix [#841](https://github.com/jeremmfr/terraform-provider-junos/issues/841))
1 change: 1 addition & 0 deletions .markdownlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ MD013:
code_blocks: false
line_length: 100
MD014: false
MD038: false
24 changes: 15 additions & 9 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,14 @@ The following arguments are supported in the `provider` block:
A `terraform refresh` will be able to detect parts of errors but **be careful with**
**this option**.
There are exceptions for resources :
- **junos_interface_physical** dont generate `chassis aggregated-devices ethernet device-count`
- **junos_interface_physical** don't generate `chassis aggregated-devices ethernet device-count`
line when it should be necessary.
- **junos_interface_st0_unit** cannot take into account the option and run still
normal process.
- **junos_null_commit_file**, the skip doesn’t, of course, concern this resource.
- **junos_null_load_config**, the skip doesn’t concern this resource either.
- **junos_interface_st0_unit** cannot take into account the option
and still run the normal process.
- **junos_null_commit_file**, the skip doesn't, of course, concern this resource.
- **junos_null_load_config**, the skip doesn't concern this resource either.
- **junos_group_raw** cannot take into account the option due to its different format
and still run the normal process.

It can also be sourced from the `JUNOS_FAKECREATE_SETFILE` environment
variable.
Expand All @@ -254,9 +256,11 @@ The following arguments are supported in the `provider` block:
in tfstate. A `terraform refresh` will be able to detect parts of errors but
**be careful with this option**.
There are exceptions for resources :
- **junos_interface_physical** dont generate `chassis aggregated-devices ethernet device-count`
- **junos_interface_physical** don't generate `chassis aggregated-devices ethernet device-count`
line when it should be necessary.
- **junos_null_commit_file**, the skip doesn’t, of course, concern this resource.
- **junos_null_commit_file**, the skip doesn't, of course, concern this resource.
- **junos_group_raw** cannot take into account the option due to its different format
and still run the normal process.

It can also be enabled from the `JUNOS_FAKEUPDATE_ALSO` environment variable and
its value is `1`, `t` or `true`.
Expand All @@ -269,9 +273,11 @@ The following arguments are supported in the `provider` block:
As with `fake_create_with_setfile`, this option may leave extra config (not managed by Terraform)
on Junos device. **Be careful with this option**.
There are exceptions for resources :
- **junos_interface_physical** dont generate `chassis aggregated-devices ethernet device-count`
- **junos_interface_physical** don't generate `chassis aggregated-devices ethernet device-count`
line when it should be necessary.
- **junos_null_commit_file**, the skip doesn’t, of course, concern this resource.
- **junos_null_commit_file**, the skip doesn't, of course, concern this resource.
- **junos_group_raw** cannot take into account the option due to its different format
and still run the normal process.

It can also be enabled from the `JUNOS_FAKEDELETE_ALSO` environment variable and
its value is `1`, `t` or `true`.
Expand Down
78 changes: 78 additions & 0 deletions docs/resources/apply_group.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
page_title: "Junos: junos_apply_group"
---

# junos_apply_group

Provides a resource to apply a Junos group at a specific configuration level.

This resource allows you to apply a group at the global level or
at a specific configuration prefix path.

-> **Note**
There is no verification that the `prefix` path exists in the Junos configuration.
Make sure the prefix is valid before applying the group.

## Example Usage

```hcl
# Create a group with raw configuration
resource "junos_group_raw" "dns_config" {
name = "dns-servers"
config = <<EOT
system {
services {
dns {
forwarders {
192.0.2.3;
192.0.2.4;
}
}
}
}
EOT
}

# Apply the group globally
resource "junos_apply_group" "dns_global" {
name = junos_group_raw.dns_config.name
}

# Apply the group at system level
resource "junos_apply_group" "dns_system" {
name = junos_group_raw.dns_config.name
prefix = "system "
}
```

## Argument Reference

The following arguments are supported:

- **name** (Required, String, Forces new resource)
Name of the group to apply.
- **prefix** (Optional, String, Forces new resource)
Prefix path to define where apply-group must be set.
If not specified, the group is applied globally.
The prefix must end with a space character.

## Attribute Reference

The following attributes are exported:

- **id** (String)
An identifier for the resource with format `<name>_-_<prefix>`.

## Import

Junos apply-group can be imported using an id made up of `<name>_-_<prefix>`, e.g.

```shell
$ terraform import junos_apply_group.dns_global "dns-servers_-_"
```

For a group applied with a prefix:

```shell
$ terraform import junos_apply_group.dns_system "dns-servers_-_system "
```
68 changes: 68 additions & 0 deletions docs/resources/apply_group_except.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
page_title: "Junos: junos_apply_group_except"
---

# junos_apply_group_except

Provides a resource to exclude a Junos group at a specific configuration level.

This resource allows you to exclude a group from being applied at a specific
configuration prefix path using the `apply-groups-except` statement.

-> **Note**
Unlike `junos_apply_group`, `apply-groups-except` cannot be applied globally.
A `prefix` is always required to specify where the group exclusion should be set.

-> **Note**
There is no verification that the `prefix` path exists in the Junos configuration.
Make sure the prefix is valid before applying the group exclusion.

## Example Usage

```hcl
# Create a group with raw configuration
resource "junos_group_raw" "system" {
name = "system-default"
format = "set"
config = <<EOT
set system time-zone Europe/Paris
set system default-address-selection
EOT
}

# Apply the group globally
resource "junos_apply_group" "base" {
name = junos_group_raw.system.name
}

# Exclude the group from system level
resource "junos_apply_group_except" "base_system" {
name = junos_group_raw.system.name
prefix = "system "
}
```

## Argument Reference

The following arguments are supported:

- **name** (Required, String, Forces new resource)
Name of the group to exclude.
- **prefix** (Required, String, Forces new resource)
Prefix path to define where apply-groups-except must be set.
The prefix must end with a space character.

## Attribute Reference

The following attributes are exported:

- **id** (String)
An identifier for the resource with format `<name>_-_<prefix>`.

## Import

Junos apply-groups-except can be imported using an id made up of `<name>_-_<prefix>`, e.g.

```shell
$ terraform import junos_apply_group_except.base_system "system-default_-_system "
```
91 changes: 91 additions & 0 deletions docs/resources/group_raw.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
---
page_title: "Junos: junos_group_raw"
---

# junos_group_raw

Provides a group resource with raw configuration.

This resource allows you to create a Junos group with
raw configuration in either text or set format.
The configuration is loaded directly without structured parsing,
giving you full flexibility to define any Junos configuration within a group.

## Example Usage

```hcl
# Create a group with text format (default)
resource "junos_group_raw" "dns_config" {
name = "dns-servers"
config = <<EOT
system {
services {
dns {
forwarders {
192.0.2.3;
192.0.2.33;
}
}
}
}
EOT
}

# Create a group with set format
resource "junos_group_raw" "system_config" {
name = "system-settings"
format = "set"
config = <<EOT
set system time-zone Europe/Paris
set system default-address-selection
set system ntp peer 192.0.2.1
EOT
}

# Apply the group
resource "junos_apply_group" "dns" {
name = junos_group_raw.dns_config.name
}

resource "junos_apply_group" "system" {
name = junos_group_raw.system_config.name
prefix = "system "
}
```

## Argument Reference

The following arguments are supported:

- **name** (Required, String, Forces new resource)
The name of the group.
- **config** (Required, String)
The raw configuration to load.
The format of this configuration depends on the `format` attribute.
- **format** (Optional, String, Forces new resource)
The format used for the configuration data.
Need to be `text` or `set`.
Defaults to `text`.
- When `text`: configuration should be in Junos text format (curly braces).
- When `set`: each line must start with `set ` and be in Junos set command format.

## Attribute Reference

The following attributes are exported:

- **id** (String)
An identifier for the resource with format `<name>_-_<format>`.

## Import

Junos group can be imported using an id made up of `<name>`, e.g.

```shell
$ terraform import junos_group_raw.dns_config "dns-servers"
```

Or with the format specified `<name>_-_<format>`:

```shell
$ terraform import junos_group_raw.system_config "system-settings_-_set"
```
3 changes: 3 additions & 0 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ func (p *junosProvider) Resources(_ context.Context) []func() resource.Resource
newApplicationsResource,
newApplicationsOrderedResource,
newApplicationSetResource,
newApplyGroupResource,
newApplyGroupExceptResource,
newBgpGroupResource,
newBgpNeighborResource,
newBridgeDomainResource,
Expand All @@ -260,6 +262,7 @@ func (p *junosProvider) Resources(_ context.Context) []func() resource.Resource
newForwardingoptionsSamplingInstanceResource,
newForwardingoptionsStormControlProfileResource,
newGenerateRouteResource,
newGroupRawResource,
newGroupDualSystemResource,
newIccpResource,
newIccpPeerResource,
Expand Down
Loading
Loading