Skip to content

Commit 0a8571a

Browse files
fix: ensure strong ansible vault password is used (#999)
* chore: ensure strong ansible vault password is used * chore: limit which characters are allowed in ansible vault password * fix: upgrade terraform-ibm-modules/powervs-instance to 2.4.1 * fix: default values for projects compatibility * fix: json format for default value
1 parent a552504 commit 0a8571a

File tree

7 files changed

+32
-10
lines changed

7 files changed

+32
-10
lines changed

ibm_catalog.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,6 @@
230230
},
231231
{
232232
"key": "vpc_intel_images",
233-
"required": true,
234233
"hidden": true
235234
},
236235
{
@@ -773,7 +772,6 @@
773772
},
774773
{
775774
"key": "vpc_intel_images",
776-
"required": true,
777775
"hidden": true
778776
},
779777
{

modules/powervs-vpc-landing-zone/submodules/ansible/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ No modules.
2727
| Name | Description | Type | Default | Required |
2828
|------|-------------|------|---------|:--------:|
2929
| <a name="input_ansible_host_or_ip"></a> [ansible\_host\_or\_ip](#input\_ansible\_host\_or\_ip) | Private IP of virtual server instance running RHEL OS on which ansible will be installed and configured to act as central ansible node. | `string` | n/a | yes |
30-
| <a name="input_ansible_vault_password"></a> [ansible\_vault\_password](#input\_ansible\_vault\_password) | Vault password to encrypt ansible variable file for SAP installation. | `string` | `null` | no |
30+
| <a name="input_ansible_vault_password"></a> [ansible\_vault\_password](#input\_ansible\_vault\_password) | Vault password to encrypt ansible playbooks that contain sensitive information. Password requirements: 15-100 characters and at least one uppercase letter, one lowercase letter, one number, and one special character. Allowed characters: A-Z, a-z, 0-9, !#$%&()*+-.:;<=>?@[]\_{\|}~. | `string` | `null` | no |
3131
| <a name="input_bastion_host_ip"></a> [bastion\_host\_ip](#input\_bastion\_host\_ip) | Jump/Bastion server public IP address to reach the ansible host which has private IP. | `string` | n/a | yes |
3232
| <a name="input_configure_ansible_host"></a> [configure\_ansible\_host](#input\_configure\_ansible\_host) | If set to true, bash script will be executed to install and configure the collections and packages on ansible node. | `bool` | n/a | yes |
3333
| <a name="input_dst_inventory_file_name"></a> [dst\_inventory\_file\_name](#input\_dst\_inventory\_file\_name) | Name for the inventory file to be generated on the Ansible host. | `string` | n/a | yes |

modules/powervs-vpc-landing-zone/submodules/ansible/variables.tf

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,32 @@ variable "inventory_template_vars" {
6060
}
6161

6262
variable "ansible_vault_password" {
63-
description = "Vault password to encrypt ansible variable file for SAP installation."
63+
description = "Vault password to encrypt ansible playbooks that contain sensitive information. Password requirements: 15-100 characters and at least one uppercase letter, one lowercase letter, one number, and one special character. Allowed characters: A-Z, a-z, 0-9, !#$%&()*+-.:;<=>?@[]_{|}~."
6464
type = string
6565
sensitive = true
6666
default = null
67+
validation {
68+
condition = var.ansible_vault_password == null ? true : (length(var.ansible_vault_password) >= 15 && length(var.ansible_vault_password) <= 100)
69+
error_message = "ansible_vault_password needs to be between 15 and 100 characters in length."
70+
}
71+
validation {
72+
condition = var.ansible_vault_password == null ? true : can(regex("[A-Z]", var.ansible_vault_password))
73+
error_message = "ansible_vault_password needs to contain at least one uppercase character (A-Z)."
74+
}
75+
validation {
76+
condition = var.ansible_vault_password == null ? true : can(regex("[a-z]", var.ansible_vault_password))
77+
error_message = "ansible_vault_password needs to contain at least one lowercase character (a-z)."
78+
}
79+
validation {
80+
condition = var.ansible_vault_password == null ? true : can(regex("[0-9]", var.ansible_vault_password))
81+
error_message = "ansible_vault_password needs to contain at least one number (0-9)."
82+
}
83+
validation {
84+
condition = var.ansible_vault_password == null ? true : can(regex("[!#$%&()*+\\-.:;<=>?@[\\]_{|}~]", var.ansible_vault_password))
85+
error_message = "ansible_vault_password needs to contain at least one of the following special characters: !#$%&()*+-.:;<=>?@[]_{|}~"
86+
}
87+
validation {
88+
condition = var.ansible_vault_password == null ? true : can(regex("^[A-Za-z0-9!#$%&()*+\\-.:;<=>?@[\\]_{|}~]+$", var.ansible_vault_password))
89+
error_message = "ansible_vault_password contains illegal characters. Allowed characters: A-Z, a-z, 0-9, !#$%&()*+-.:;<=>?@[]_{|}~"
90+
}
6791
}

solutions/standard-plus-vsi/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ This example sets up the following infrastructure:
5454

5555
| Name | Source | Version |
5656
|------|--------|---------|
57-
| <a name="module_powervs_instance"></a> [powervs\_instance](#module\_powervs\_instance) | terraform-ibm-modules/powervs-instance/ibm | 2.4.0 |
57+
| <a name="module_powervs_instance"></a> [powervs\_instance](#module\_powervs\_instance) | terraform-ibm-modules/powervs-instance/ibm | 2.4.1 |
5858
| <a name="module_standard"></a> [standard](#module\_standard) | ../../modules/powervs-vpc-landing-zone | n/a |
5959

6060
### Resources

solutions/standard-plus-vsi/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ module "standard" {
4040

4141
module "powervs_instance" {
4242
source = "terraform-ibm-modules/powervs-instance/ibm"
43-
version = "2.4.0"
43+
version = "2.4.1"
4444
providers = { ibm = ibm.ibm-pi }
4545

4646
pi_workspace_guid = module.standard.powervs_workspace_guid

solutions/standard-plus-vsi/variables.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ variable "vpc_intel_images" {
7575
sles_image = string
7676
})
7777
default = {
78-
rhel_image = "ibm-redhat-9-4-amd64-sap-applications-3"
79-
sles_image = "ibm-sles-15-5-amd64-sap-applications-4"
78+
"rhel_image" : "ibm-redhat-9-4-amd64-sap-applications-3"
79+
"sles_image" : "ibm-sles-15-5-amd64-sap-applications-4"
8080
}
8181
}
8282

solutions/standard/variables.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ variable "vpc_intel_images" {
7676
sles_image = string
7777
})
7878
default = {
79-
rhel_image = "ibm-redhat-9-4-amd64-sap-applications-3"
80-
sles_image = "ibm-sles-15-5-amd64-sap-applications-4"
79+
"rhel_image" : "ibm-redhat-9-4-amd64-sap-applications-3"
80+
"sles_image" : "ibm-sles-15-5-amd64-sap-applications-4"
8181
}
8282
}
8383

0 commit comments

Comments
 (0)