diff --git a/examples/unfurl-technology---boutique---plus-maintenance-automated/lib/tosca-vintner-profile-extended.yaml b/examples/unfurl-technology---boutique---plus-maintenance-automated/lib/tosca-vintner-profile-extended.yaml index 3bccb0cc3c..b21760815a 100644 --- a/examples/unfurl-technology---boutique---plus-maintenance-automated/lib/tosca-vintner-profile-extended.yaml +++ b/examples/unfurl-technology---boutique---plus-maintenance-automated/lib/tosca-vintner-profile-extended.yaml @@ -9440,39 +9440,42 @@ node_types: inputs: playbook: q: - - name: forward port - ansible.builtin.shell: kubectl port-forward service/{{ HOST.dbms_name }} 23306:3306 - args: - executable: /usr/bin/bash - async: 30 - poll: 0 - - name: wait for port - ansible.builtin.wait_for: - host: 127.0.0.1 - port: 23306 - delay: 5 - timeout: 30 - - name: create database - community.mysql.mysql_db: - name: '{{ SELF.database_name }}' - login_host: 127.0.0.1 - login_password: '{{ HOST.dbms_password }}' - login_port: '23306' - login_user: root - - name: create user (with privileges) - community.mysql.mysql_user: - name: '{{ SELF.database_user }}' - password: '{{ SELF.database_password }}' - host: '%' - priv: '*.*:ALL' - login_host: 127.0.0.1 - login_password: '{{ HOST.dbms_password }}' - login_port: '23306' - login_user: root - - name: unforward port - ansible.builtin.shell: pkill -f "kubectl port-forward service/{{ HOST.dbms_name }}" - args: - executable: /usr/bin/bash + - name: deploy database + block: + - name: forward port + ansible.builtin.shell: kubectl port-forward service/{{ HOST.dbms_name }} 23306:3306 + args: + executable: /usr/bin/bash + async: 30 + poll: 0 + - name: wait for port + ansible.builtin.wait_for: + host: 127.0.0.1 + port: 23306 + delay: 5 + timeout: 30 + - name: create database + community.mysql.mysql_db: + name: '{{ SELF.database_name }}' + login_host: 127.0.0.1 + login_password: '{{ HOST.dbms_password }}' + login_port: '23306' + login_user: root + - name: create user (with privileges) + community.mysql.mysql_user: + name: '{{ SELF.database_user }}' + password: '{{ SELF.database_password }}' + host: '%' + priv: '*.*:ALL' + login_host: 127.0.0.1 + login_password: '{{ HOST.dbms_password }}' + login_port: '23306' + login_user: root + always: + - name: unforward port + ansible.builtin.shell: pkill -f "kubectl port-forward service/{{ HOST.dbms_name }}" + args: + executable: /usr/bin/bash mysql.database~mysql.database::ansible@mysql.dbms->virtual.machine: derived_from: mysql.database metadata: @@ -9699,6 +9702,65 @@ node_types: type: string default: get_input: k8s_client_key_file + interfaces: + Standard: + operations: + configure: + implementation: + primary: Terraform + delete: + implementation: + primary: Terraform + defaults: + inputs: + main: + terraform: + - required_providers: + - mysql: + source: petoju/mysql + version: 3.0.48 + provider: + mysql: + - endpoint: ${terraform_data.forward_port.input} + password: '{{ HOST.dbms_password }}' + username: root + resource: + terraform_data: + forward_port: + - input: 127.0.0.1:23306 + provisioner: + local-exec: + command: |- + (nohup kubectl port-forward service/{{ HOST.dbms_name }} 23306:3306 > /dev/null 2>&1 &) + sleep 5s + interpreter: + - /bin/bash + - '-c' + unforward_port: + - depends_on: + - mysql_grant.user + provisioner: + local-exec: + command: pkill -f "kubectl port-forward service/{{ HOST.dbms_name }}" + interpreter: + - /bin/bash + - '-c' + mysql_database: + database: + - name: '{{ SELF.database_name }}' + mysql_user: + user: + - host: '%' + plaintext_password: '{{ SELF.database_password }}' + user: '{{ SELF.database_user }}' + mysql_grant: + user: + - database: '{{ SELF.database_name }}' + host: '%' + table: '*' + privileges: + - ALL + user: ${mysql_user.user.user} mysql.database~mysql.database::terraform@mysql.dbms->virtual.machine: derived_from: mysql.database metadata: diff --git a/examples/unfurl-technology---boutique---plus-maintenance-automated/scripts/configuration.env b/examples/unfurl-technology---boutique---plus-maintenance-automated/scripts/configuration.env index 08434adc5e..539633fc56 100644 --- a/examples/unfurl-technology---boutique---plus-maintenance-automated/scripts/configuration.env +++ b/examples/unfurl-technology---boutique---plus-maintenance-automated/scripts/configuration.env @@ -2,4 +2,4 @@ TEMPLATE_NAME="technology-gcp" #VINTNER="node ../../../build/cli/index.js" VINTNER="../../../task vintner" ORCHESTRATOR="unfurl" -VARIANT="gcp" +VARIANT="kubernetes" diff --git a/examples/unfurl-technology---shop---plus-maintenance-automated/lib/tosca-vintner-profile-extended.yaml b/examples/unfurl-technology---shop---plus-maintenance-automated/lib/tosca-vintner-profile-extended.yaml index 3bccb0cc3c..9555058ed1 100644 --- a/examples/unfurl-technology---shop---plus-maintenance-automated/lib/tosca-vintner-profile-extended.yaml +++ b/examples/unfurl-technology---shop---plus-maintenance-automated/lib/tosca-vintner-profile-extended.yaml @@ -9699,6 +9699,66 @@ node_types: type: string default: get_input: k8s_client_key_file + interfaces: + Standard: + operations: + configure: + implementation: + primary: Terraform + delete: + implementation: + primary: Terraform + defaults: + inputs: + main: + terraform: + - required_providers: + - mysql: + source: petoju/mysql + version: 3.0.48 + provider: + mysql: + - endpoint: ${terraform_data.forward_port.endpoint} + password: '{{ HOST.dbms_password }}' + username: root + resource: + terraform_data: + forward_port: + - input: + endpoint: 127.0.0.1:23306 + provisioner: + local-exec: + command: |- + nohup kubectl port-forward service/{{ HOST.dbms_name }} 23306:3306 & + sleep 5s + interpreter: + - /bin/bash + - '-c' + unforward_port: + - depends_on: + - mysql_grant.user + provisioner: + local-exec: + command: pkill -f "kubectl port-forward service/{{ HOST.dbms_name }}" + interpreter: + - /bin/bash + - '-c' + mysql_database: + database: + - name: '{{ SELF.database_name }}' + mysql_user: + user: + - host: '%' + plaintext_password: '{{ SELF.database_password }}' + user: '{{ SELF.database_user }}' + mysql_grant: + user: + - database: '{{ SELF.database_name }}' + host: '%' + table: '*' + privileges: + - ALL + user: ${mysql_user.user.user} mysql.database~mysql.database::terraform@mysql.dbms->virtual.machine: derived_from: mysql.database metadata: diff --git a/examples/unfurl-technology---shop---plus-maintenance-automated/scripts/clean.sh b/examples/unfurl-technology---shop---plus-maintenance-automated/scripts/clean.sh old mode 100644 new mode 100755 diff --git a/examples/unfurl-technology---shop---plus-maintenance-automated/scripts/code.sh b/examples/unfurl-technology---shop---plus-maintenance-automated/scripts/code.sh old mode 100644 new mode 100755 diff --git a/examples/unfurl-technology---shop---plus-maintenance-automated/scripts/configuration.env b/examples/unfurl-technology---shop---plus-maintenance-automated/scripts/configuration.env index e88630fbd2..d7223753e6 100644 --- a/examples/unfurl-technology---shop---plus-maintenance-automated/scripts/configuration.env +++ b/examples/unfurl-technology---shop---plus-maintenance-automated/scripts/configuration.env @@ -1,5 +1,5 @@ TEMPLATE_NAME="technology-maintenance" #VINTNER="node ../../../build/cli/index.js" VINTNER="../../../task vintner" -VARIANT="static" +VARIANT="kubernetes" diff --git a/examples/unfurl-technology---shop---plus-maintenance-automated/scripts/configuration.sh b/examples/unfurl-technology---shop---plus-maintenance-automated/scripts/configuration.sh old mode 100644 new mode 100755 diff --git a/examples/unfurl-technology---shop---plus-maintenance-automated/scripts/continue.sh b/examples/unfurl-technology---shop---plus-maintenance-automated/scripts/continue.sh old mode 100644 new mode 100755 diff --git a/examples/unfurl-technology---shop---plus-maintenance-automated/scripts/deploy.sh b/examples/unfurl-technology---shop---plus-maintenance-automated/scripts/deploy.sh old mode 100644 new mode 100755 diff --git a/examples/unfurl-technology---shop---plus-maintenance-automated/scripts/enrich.sh b/examples/unfurl-technology---shop---plus-maintenance-automated/scripts/enrich.sh old mode 100644 new mode 100755 diff --git a/examples/unfurl-technology---shop---plus-maintenance-automated/scripts/implement.sh b/examples/unfurl-technology---shop---plus-maintenance-automated/scripts/implement.sh old mode 100644 new mode 100755 diff --git a/examples/unfurl-technology---shop---plus-maintenance-automated/scripts/pull.sh b/examples/unfurl-technology---shop---plus-maintenance-automated/scripts/pull.sh old mode 100644 new mode 100755 diff --git a/examples/unfurl-technology---shop---plus-maintenance-automated/scripts/quality.sh b/examples/unfurl-technology---shop---plus-maintenance-automated/scripts/quality.sh old mode 100644 new mode 100755 diff --git a/examples/unfurl-technology---shop---plus-maintenance-automated/scripts/reimport.sh b/examples/unfurl-technology---shop---plus-maintenance-automated/scripts/reimport.sh old mode 100644 new mode 100755 diff --git a/examples/unfurl-technology---shop---plus-maintenance-automated/scripts/setup.sh b/examples/unfurl-technology---shop---plus-maintenance-automated/scripts/setup.sh old mode 100644 new mode 100755 diff --git a/examples/unfurl-technology---shop---plus-maintenance-automated/scripts/study.sh b/examples/unfurl-technology---shop---plus-maintenance-automated/scripts/study.sh old mode 100644 new mode 100755 diff --git a/examples/unfurl-technology---shop---plus-maintenance-automated/scripts/swap-lib.sh b/examples/unfurl-technology---shop---plus-maintenance-automated/scripts/swap-lib.sh old mode 100644 new mode 100755 diff --git a/examples/unfurl-technology---shop---plus-maintenance-automated/scripts/undeploy.sh b/examples/unfurl-technology---shop---plus-maintenance-automated/scripts/undeploy.sh old mode 100644 new mode 100755 diff --git a/src/technologies/plugins/rules/generators/mysql-database/ansible/mysql-dbms/kubernetes-cluster/index.ts b/src/technologies/plugins/rules/generators/mysql-database/ansible/mysql-dbms/kubernetes-cluster/index.ts index 5e37d0a31d..c6f976de52 100644 --- a/src/technologies/plugins/rules/generators/mysql-database/ansible/mysql-dbms/kubernetes-cluster/index.ts +++ b/src/technologies/plugins/rules/generators/mysql-database/ansible/mysql-dbms/kubernetes-cluster/index.ts @@ -36,54 +36,61 @@ const generator: ImplementationGenerator = { playbook: { q: [ { - name: 'forward port', - 'ansible.builtin.shell': - 'kubectl port-forward service/{{ HOST.dbms_name }} 23306:3306', - args: { - executable: '/usr/bin/bash', - }, - async: 30, - poll: 0, - }, - { - name: 'wait for port', - 'ansible.builtin.wait_for': { - host: '127.0.0.1', - port: 23306, - delay: 5, - timeout: 30, - }, - }, - { - name: 'create database', - 'community.mysql.mysql_db': { - name: '{{ SELF.database_name }}', - login_host: '127.0.0.1', - login_password: '{{ HOST.dbms_password }}', - login_port: '23306', - login_user: 'root', - }, - }, - { - name: 'create user (with privileges)', - 'community.mysql.mysql_user': { - name: '{{ SELF.database_user }}', - password: '{{ SELF.database_password }}', - host: '%', - priv: '*.*:ALL', - login_host: '127.0.0.1', - login_password: '{{ HOST.dbms_password }}', - login_port: '23306', - login_user: 'root', - }, - }, - { - name: 'unforward port', - 'ansible.builtin.shell': - 'pkill -f "kubectl port-forward service/{{ HOST.dbms_name }}"', - args: { - executable: '/usr/bin/bash', - }, + name: 'deploy database', + block: [ + { + name: 'forward port', + 'ansible.builtin.shell': + 'kubectl port-forward service/{{ HOST.dbms_name }} 23306:3306', + args: { + executable: '/usr/bin/bash', + }, + async: 30, + poll: 0, + }, + { + name: 'wait for port', + 'ansible.builtin.wait_for': { + host: '127.0.0.1', + port: 23306, + delay: 5, + timeout: 30, + }, + }, + { + name: 'create database', + 'community.mysql.mysql_db': { + name: '{{ SELF.database_name }}', + login_host: '127.0.0.1', + login_password: '{{ HOST.dbms_password }}', + login_port: '23306', + login_user: 'root', + }, + }, + { + name: 'create user (with privileges)', + 'community.mysql.mysql_user': { + name: '{{ SELF.database_user }}', + password: '{{ SELF.database_password }}', + host: '%', + priv: '*.*:ALL', + login_host: '127.0.0.1', + login_password: '{{ HOST.dbms_password }}', + login_port: '23306', + login_user: 'root', + }, + }, + ], + always: [ + { + name: 'unforward port', + 'ansible.builtin.shell': + 'pkill -f "kubectl port-forward service/{{ HOST.dbms_name }}"', + args: { + executable: '/usr/bin/bash', + }, + }, + ], }, ], }, diff --git a/src/technologies/plugins/rules/generators/mysql-database/terraform/mysql-dbms/kubernetes-cluster/index.ts b/src/technologies/plugins/rules/generators/mysql-database/terraform/mysql-dbms/kubernetes-cluster/index.ts index 75641390d2..a24e488f48 100644 --- a/src/technologies/plugins/rules/generators/mysql-database/terraform/mysql-dbms/kubernetes-cluster/index.ts +++ b/src/technologies/plugins/rules/generators/mysql-database/terraform/mysql-dbms/kubernetes-cluster/index.ts @@ -6,8 +6,6 @@ import { TerraformStandardOperations, } from '#technologies/plugins/rules/utils' -// TODO: next: test this - // TODO: use k8s auth /** @@ -62,7 +60,7 @@ const generator: ImplementationGenerator = { provider: { mysql: [ { - endpoint: '${terraform_data.forward_port.endpoint}', + endpoint: '${terraform_data.forward_port.input}', password: '{{ HOST.dbms_password }}', username: 'root', }, @@ -72,13 +70,11 @@ const generator: ImplementationGenerator = { terraform_data: { forward_port: [ { - input: { - endpoint: '127.0.0.1:23306', - }, + input: '127.0.0.1:23306', provisioner: { 'local-exec': { command: [ - 'nohup kubectl port-forward service/{{ HOST.dbms_name }} 23306:3306 &', + '(nohup kubectl port-forward service/{{ HOST.dbms_name }} 23306:3306 > /dev/null 2>&1 &)', 'sleep 5s', ].join('\n'), interpreter: ['/bin/bash', '-c'], @@ -86,7 +82,6 @@ const generator: ImplementationGenerator = { }, }, ], - unforward_port: [ { depends_on: ['mysql_grant.user'],