Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
milesstoetzner committed Sep 3, 2024
1 parent 364e3c3 commit c9d1c49
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9949,3 +9949,57 @@ node_types:
type: string
default:
get_input: os_ssh_key_file
interfaces:
Standard:
operations:
create:
implementation:
primary: Ansible
operation_host: HOST
environment:
ANSIBLE_HOST_KEY_CHECKING: 'False'
inputs:
playbook:
q:
- name: wait for ssh
wait_for_connection:
- name: touch compose
register: compose
ansible.builtin.tempfile:
suffix: '{{ SELF.database_name }}-{{ HOST.dbms_name }}.database.compose.yaml'
- name: create compose
ansible.builtin.copy:
dest: '{{ compose.path }}'
content: '{{ manifest | to_yaml }}'
vars:
manifest:
name: '{{ SELF.database_name }}-{{ HOST.dbms_name }}-database-job'
services:
job:
container_name: '{{ SELF.database_name }}-{{ HOST.dbms_name }}-database-job'
image: mysql:{{ HOST.dbms_version }}
network_mode: host
command:
- mysql
- '--host={{ HOST.management_address }}'
- '--port={{ HOST.management_port }}'
- '--user=root'
- '--password={{ HOST.dbms_password }}'
- '-e'
- CREATE DATABASE IF NOT EXISTS {{ SELF.database_name }}; CREATE USER IF NOT EXISTS '{{ SELF.database_user }}'@'%' IDENTIFIED BY '{{ SELF.database_password }}'; GRANT ALL PRIVILEGES ON *.* TO '{{ SELF.database_user }}'@'%';
- name: apply compose
ansible.builtin.shell: docker compose -f {{ compose.path }} up -d
args:
executable: /usr/bin/bash
- name: give job some time
ansible.builtin.pause:
seconds: 10
- name: unapply compose
ansible.builtin.shell: docker compose -f {{ compose.path }} down
args:
executable: /usr/bin/bash
playbookArgs:
- '--become'
- '--key-file={{ SELF.os_ssh_key_file }}'
- '--user={{ SELF.os_ssh_user }}'
delete: exit 0
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ TEMPLATE_NAME="technology-gcp"
#VINTNER="node ../../../build/cli/index.js"
VINTNER="../../../task vintner"
ORCHESTRATOR="unfurl"
VARIANT="kubernetes"
VARIANT="os-medium"
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,8 @@ topology_template:

cart_database:
type: mysql.database
# TODO: remove this
technology: compose
properties:
- database_name: cart
- database_user: cart
Expand Down
4 changes: 0 additions & 4 deletions src/controller/template/implement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ export default async function (options: TemplateImplementOptions) {
* Implement
*/
for (const file of files.walkDirectory(lib, {extensions: YAML_EXTENSIONS})) {
std.log(`processing file "${file}"`)

const templateString = files.loadFile(file)
const templateData: ServiceTemplate = files.loadYAML<ServiceTemplate>(file)

Expand Down Expand Up @@ -131,8 +129,6 @@ export default async function (options: TemplateImplementOptions) {
// Ignore abstract types
if (isAbstract(baseType)) continue

std.log(`processing node type "${baseName}"`)

for (const plugin of graph.plugins.technology) {
for (const [implementationName, implementationType] of Object.entries(
plugin.implement(baseName, baseType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@ import {
OpenstackMachineCredentials,
} from '#technologies/plugins/rules/utils'

// TODO: next: test this

// TODO: we assume that dbms is exposed

const generator: ImplementationGenerator = {
component: 'mysql.database',
technology: 'compose',
hosting: ['mysql.dbms', 'docker.engine', 'virtual.machine'],
weight: 0,
reason: 'One-time use docker container ("fake Kubernetes job") with imperative parts, while declarative other technologies provide declarative modules.',
reason: 'One-time use docker container ("fake Kubernetes job") with imperative parts, while other technologies provide declarative modules.',

generate: (name, type) => {
return {
Expand Down Expand Up @@ -57,7 +55,7 @@ const generator: ImplementationGenerator = {
},
vars: {
manifest: {
name: '{{ SELF.dbms_name }}',
name: '{{ SELF.database_name }}-{{ HOST.dbms_name }}-database-job',
services: {
job: {
container_name:
Expand Down
1 change: 0 additions & 1 deletion src/technologies/plugins/rules/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ export class TechnologyRulePlugin implements TechnologyPlugin {
continue
}

std.log(`Generating implementation "${implementationName}" based on generator "${generatorName}"`)
const implementation = generator.generate(name, type)
assert.isDefined(implementation.metadata)
assert.isDefined(implementation.metadata[METADATA.VINTNER_GENERATED])
Expand Down

0 comments on commit c9d1c49

Please sign in to comment.