persist infrastructure and plattform

This commit is contained in:
Marcel Arndt
2025-04-10 17:31:33 +02:00
parent f81ae2f2e7
commit 98aeb82ff6
7 changed files with 230 additions and 35 deletions
+3
View File
@@ -0,0 +1,3 @@
config:
avicenna-infrastructure:hcloudToken:
secure: AAABAIi5Eso+isiy15TT2VC45yG73iLmuwhaDFi8180Gm0Vd9zdVSmh9HRPXQMlSU+NxzQDqOx5qbgqvMDiyew4AHkEgUJvJUA0cV0Mn1B4WeGlhzzYmbgdHeVobgv8i
+39 -34
View File
@@ -22,8 +22,13 @@ const sshKey = new tls.PrivateKey('sshKey', {
export const privateKey = sshKey.privateKeyOpenssh;
const env = pulumi.getStack();
if (!fs.existsSync(`./.local/${env}`)) {
fs.mkdirSync(`./.local/${env}`);
}
privateKey.apply((privKey) =>
fs.writeFileSync('././local/private_key', privKey, { mode: '0600' })
fs.writeFileSync(`./.local/${env}/private_key`, privKey, { mode: '0600' })
);
const hetznerSshKey = new hcloud.SshKey(
@@ -163,40 +168,40 @@ async function createSwarmCluster(nodeCount: number) {
return vm;
}
const geniusceo = digitalocean.Domain.get(
'geniusceo',
'genius.ceo',
);
const doToken = config.getSecret('doToken');
if (doToken) {
const geniusceo = digitalocean.Domain.get('geniusceo', 'genius.ceo');
const wwwSubDomain = geniusceo.id.apply(
(id) =>
new digitalocean.DnsRecord('www', {
domain: id,
type: 'A',
value: swarmMaster.ipv4Address,
name: 'www',
})
);
const wwwSubDomain = geniusceo.id.apply(
(id) =>
new digitalocean.DnsRecord('www', {
domain: id,
type: 'A',
value: swarmMaster.ipv4Address,
name: 'www',
})
);
const noSubDomain = geniusceo.id.apply(
(id) =>
new digitalocean.DnsRecord('noSub', {
domain: id,
type: 'A',
value: swarmMaster.ipv4Address,
name: '@',
})
);
const noSubDomain = geniusceo.id.apply(
(id) =>
new digitalocean.DnsRecord('noSub', {
domain: id,
type: 'A',
value: swarmMaster.ipv4Address,
name: '@',
})
);
const wildcardSubDomain = geniusceo.id.apply(
(id) =>
new digitalocean.DnsRecord('*', {
domain: id,
type: 'A',
value: swarmMaster.ipv4Address,
name: '*',
})
);
const wildcardSubDomain = geniusceo.id.apply(
(id) =>
new digitalocean.DnsRecord('*', {
domain: id,
type: 'A',
value: swarmMaster.ipv4Address,
name: '*',
})
);
}
const installAnsibleDepsCmd = new command.remote.Command(
'installAnsibleDepsCmd',
@@ -213,7 +218,7 @@ const installAnsibleDepsCmd = new command.remote.Command(
const deployDockerStackCmd = new command.local.Command(
'deployDockerStackCmd',
{
create: pulumi.interpolate`ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -u root -i "${swarmMaster.ipv4Address}," --private-key ./private_key ansible/playbook.yml`,
create: pulumi.interpolate`ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -u root -i "${swarmMaster.ipv4Address}," --private-key ./.local/${env}/private_key ansible/playbook.yml`,
},
{
dependsOn: [installAnsibleDepsCmd],
@@ -233,4 +238,4 @@ const restartCmd = new command.remote.Command(
{
dependsOn: [deployDockerStackCmd],
}
);
);