Open RavinderReddyF5 opened 4 years ago
Comment by RavinderReddyF5 Thursday Aug 22, 2019 at 07:15 GMT
@jlosito Hope Below Behavior Solves your requirement, please comment so that i can submit fix.
First time terraform apply without status attribute mentioned in .tf file:
root@terraformclient:~/Go_Workspace/src/github.com/terraform-providers/terraform-provider-bigip# terraform apply
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
# bigip_ltm_virtual_server.test-vs will be created
+ resource "bigip_ltm_virtual_server" "test-vs" {
+ client_profiles = [
+ "/Common/tcp",
]
+ destination = "10.255.255.254"
+ fallback_persistence_profile = "/Common/dest_addr"
+ id = (known after apply)
+ ip_protocol = "tcp"
+ mask = "255.255.255.255"
+ name = "/Common/test-vs"
+ persistence_profiles = [
+ "/Common/source_addr",
]
+ port = 9999
+ profiles = [
+ "/Common/http",
]
+ server_profiles = [
+ "/Common/tcp-lan-optimized",
]
+ snatpool = (known after apply)
+ source = "0.0.0.0/0"
+ source_address_translation = "automap"
+ status = "enabled"
+ translate_address = (known after apply)
+ translate_port = (known after apply)
+ vlans_enabled = (known after apply)
}
Plan: 1 to add, 0 to change, 0 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
bigip_ltm_virtual_server.test-vs: Creating...
bigip_ltm_virtual_server.test-vs: Creation complete after 0s [id=/Common/test-vs]
Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
Terraform show output:
root@terraformclient:~/Go_Workspace/src/github.com/terraform-providers/terraform-provider-bigip# terraform show
# bigip_ltm_virtual_server.test-vs:
resource "bigip_ltm_virtual_server" "test-vs" {
client_profiles = [
"/Common/tcp",
]
destination = "10.255.255.254"
fallback_persistence_profile = "/Common/dest_addr"
id = "/Common/test-vs"
ip_protocol = "tcp"
mask = "255.255.255.255"
name = "/Common/test-vs"
persistence_profiles = [
"/Common/source_addr",
]
port = 9999
profiles = [
"/Common/http",
]
server_profiles = [
"/Common/tcp-lan-optimized",
]
source = "0.0.0.0/0"
source_address_translation = "automap"
status = "enabled"
translate_address = "enabled"
translate_port = "enabled"
vlans_enabled = false
}
Second time terraform apply
root@terraformclient:~/Go_Workspace/src/github.com/terraform-providers/terraform-provider-bigip# terraform apply
bigip_ltm_virtual_server.test-vs: Refreshing state... [id=/Common/test-vs]
Apply complete! Resources: 0 added, 0 changed, 0 destroyed.
Change status to disabled in .tf file and apply
root@terraformclient:~/Go_Workspace/src/github.com/terraform-providers/terraform-provider-bigip# terraform apply
bigip_ltm_virtual_server.test-vs: Refreshing state... [id=/Common/test-vs]
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
~ update in-place
Terraform will perform the following actions:
# bigip_ltm_virtual_server.test-vs will be updated in-place
~ resource "bigip_ltm_virtual_server" "test-vs" {
client_profiles = [
"/Common/tcp",
]
destination = "10.255.255.254"
fallback_persistence_profile = "/Common/dest_addr"
id = "/Common/test-vs"
ip_protocol = "tcp"
irules = []
mask = "255.255.255.255"
name = "/Common/test-vs"
persistence_profiles = [
"/Common/source_addr",
]
policies = []
port = 9999
profiles = [
"/Common/http",
]
server_profiles = [
"/Common/tcp-lan-optimized",
]
source = "0.0.0.0/0"
source_address_translation = "automap"
~ status = "enabled" -> "disabled"
translate_address = "enabled"
translate_port = "enabled"
vlans = []
vlans_enabled = false
}
Plan: 0 to add, 1 to change, 0 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
bigip_ltm_virtual_server.test-vs: Modifying... [id=/Common/test-vs]
bigip_ltm_virtual_server.test-vs: Modifications complete after 0s [id=/Common/test-vs]
Apply complete! Resources: 0 added, 1 changed, 0 destroyed.
root@terraformclient:~/Go_Workspace/src/github.com/terraform-providers/terraform-provider-bigip# terraform show
# bigip_ltm_virtual_server.test-vs:
resource "bigip_ltm_virtual_server" "test-vs" {
client_profiles = [
"/Common/tcp",
]
destination = "10.255.255.254"
fallback_persistence_profile = "/Common/dest_addr"
id = "/Common/test-vs"
ip_protocol = "tcp"
irules = []
mask = "255.255.255.255"
name = "/Common/test-vs"
persistence_profiles = [
"/Common/source_addr",
]
policies = []
port = 9999
profiles = [
"/Common/http",
]
server_profiles = [
"/Common/tcp-lan-optimized",
]
source = "0.0.0.0/0"
source_address_translation = "automap"
status = "disabled"
translate_address = "enabled"
translate_port = "enabled"
vlans = []
vlans_enabled = false
}
root@terraformclient:~/Go_Workspace/src/github.com/terraform-providers/terraform-provider-bigip# terraform destroy
bigip_ltm_virtual_server.test-vs: Refreshing state... [id=/Common/test-vs]
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
- destroy
Terraform will perform the following actions:
# bigip_ltm_virtual_server.test-vs will be destroyed
- resource "bigip_ltm_virtual_server" "test-vs" {
- client_profiles = [
- "/Common/tcp",
] -> null
- destination = "10.255.255.254" -> null
- fallback_persistence_profile = "/Common/dest_addr" -> null
- id = "/Common/test-vs" -> null
- ip_protocol = "tcp" -> null
- irules = [] -> null
- mask = "255.255.255.255" -> null
- name = "/Common/test-vs" -> null
- persistence_profiles = [
- "/Common/source_addr",
] -> null
- policies = [] -> null
- port = 9999 -> null
- profiles = [
- "/Common/http",
] -> null
- server_profiles = [
- "/Common/tcp-lan-optimized",
] -> null
- source = "0.0.0.0/0" -> null
- source_address_translation = "automap" -> null
- status = "disabled" -> null
- translate_address = "enabled" -> null
- translate_port = "enabled" -> null
- vlans = [] -> null
- vlans_enabled = false -> null
}
Plan: 0 to add, 0 to change, 1 to destroy.
Do you really want to destroy all resources?
Terraform will destroy all your managed infrastructure, as shown above.
There is no undo. Only 'yes' will be accepted to confirm.
Enter a value: yes
bigip_ltm_virtual_server.test-vs: Destroying... [id=/Common/test-vs]
bigip_ltm_virtual_server.test-vs: Destruction complete after 0s
Destroy complete! Resources: 1 destroyed.
Comment by dannyk81 Thursday Aug 22, 2019 at 11:07 GMT
@RavinderReddyF5 shouldn't this attribute be named state
and not status
, for consistency.
Comment by jlosito Thursday Aug 22, 2019 at 11:54 GMT
I'm a little confused @RavinderReddyF5. Are we staying that an addition attribute will be created in the schema of the virtual server resource? In other words, I'm wondering if this functionality does not currently exist and that we need to add this functionality. I currently don't see a status nor state attribute.
If we need to add this functionality, I think you're approach is great! If we can though, I would like to take @dannyk81's suggestion of calling the attribute state rather than status simply because the name for this property in the GUI of the F5 calls it "State".
Comment by dannyk81 Thursday Aug 22, 2019 at 12:05 GMT
@jlosito indeed, the current implementation doesn't include an attribute in the Virtual Server resource that can set the State
of the VS, @RavinderReddyF5's outputs above seem to suggest he's added the code for this, but I haven't seen a PR so seems like a local dev branch.
Looking forward for the PR.
Comment by RavinderReddyF5 Thursday Aug 22, 2019 at 12:10 GMT
@jlosito @dannyk81 ,
yes this functionality is not available in present implementation. will send out PR for same,modified attribute to state
from status
Comment by RavinderReddyF5 Friday Aug 23, 2019 at 07:23 GMT
@jlosito @dannyk81 Submitted PR for same: https://github.com/terraform-providers/terraform-provider-bigip/pull/153
Test Logs:
=== RUN TestAccBigipLtmVS_create
--- PASS: TestAccBigipLtmVS_create (2.36s)
=== RUN TestAccBigipLtmVS_create_Defaultstate
--- PASS: TestAccBigipLtmVS_create_Defaultstate (2.28s)
=== RUN TestAccBigipLtmVS_Modify_stateDisabledtoEnabled
--- PASS: TestAccBigipLtmVS_Modify_stateDisabledtoEnabled (2.17s)
=== RUN TestAccBigipLtmVS_Modify_stateEnabledtoDisabled
--- PASS: TestAccBigipLtmVS_Modify_stateEnabledtoDisabled (2.35s)
=== RUN TestAccBigipLtmVS_import
--- PASS: TestAccBigipLtmVS_import (2.10s)
PASS
ok github.com/terraform-providers/terraform-provider-bigip/bigip 11.279s
Issue by jlosito Monday Aug 19, 2019 at 19:19 GMT Originally opened as https://github.com/terraform-providers/terraform-provider-bigip/issues/152
Is there currently a way to modify a virtual server's property called "State" to either "Enabled" or "Disabled"? What I'm referring to is something similar to the following link for nodes. I don't see any attributes in the source code of the virtual server resource that may be able to change the state nor do I see any on the documentation page.
In other words, I would like to do something like the following: