This repository was archived by the owner on Dec 15, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathprovision.ts
More file actions
98 lines (82 loc) · 3 KB
/
provision.ts
File metadata and controls
98 lines (82 loc) · 3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import { Config, Flags} from '@oclif/core'
import AnsibleCmd from '../abstracts/base-cmd-abstract-ansible.js'
export default class ProvisionCmd extends AnsibleCmd {
static description = 'Provision containers with Ansible playbooks.'
static flags = {
branch: Flags.string({
char: 'b',
default: '2.x',
description: 'The branch of ce-provision to use for provisioning your containers. See https://gitlab.com/code-enigma/ce-provision for options.'
}),
config: Flags.string({
char: 'c',
default: '1.x',
description: 'The branch of the ce-provision-config repository. See https://gitlab.com/code-enigma/ce-dev-ce-provision-config for options.'
}),
interpreter: Flags.string({
char: 'i',
default: '/usr/bin/python',
description: 'The path to the Python interpreter to use on the target container.'
}),
ansiblepath: Flags.string({
char: 'a',
default: '/home/ce-dev/ansible/bin',
description: 'The path to the Ansible binaries on the controller container.'
}),
help: Flags.help({char: 'h'}),
verbose: Flags.boolean({
char: 'v',
description: 'Enable verbose output in Ansible.'
}),
}
protected ansibleProjectPlaybooksPath = '/home/ce-dev/projects-playbooks/provision'
protected ansibleScript = 'scripts/provision.sh'
protected ansibleScriptsPath = '/home/ce-dev/ce-provision'
protected configBranch = '1.x'
protected ownBranch = '2.x'
protected ansiblePythonInterpreter = '/usr/bin/python'
protected ansibleBinaryPath = '/home/ce-dev/ansible/bin'
protected verbose = false
/**
* @inheritdoc
*/
public constructor(argv: string[], config: Config) {
super(argv, config)
this.ansiblePaths = this.activeProjectInfo.provision
}
/**
* @inheritDoc
*/
protected getCommandParameters(ansiblePath: string): string {
const workspace = this.ansibleProjectPlaybooksPath
const repo = this.activeProjectInfo.project_name
let cmd = '--own-branch ' + this.ownBranch
if (this.verbose) {
cmd += ' --debug'
}
cmd += ' --config-branch ' + this.configBranch
cmd += ' --workspace ' + workspace
cmd += ' --repo ' + repo
cmd += ' --branch ce-dev --playbook ' + ansiblePath
//cmd += ' --python-interpreter ' + this.ansiblePythonInterpreter
//cmd += ' --ansible-path ' + this.ansibleBinaryPath
cmd += ' --ansible-extra-vars \'{"is_local":"true","_ce_dev_mkcert_base":"/home/ce-dev/.local/share/mkcert","ce_dev_host_platform":"' + this.config.platform + '"}\''
return cmd
}
/**
* @inheritdoc
*
* We need to overwrite this function to read the flags.
*/
async run(): Promise<void> {
const {flags} = await this.parse(ProvisionCmd)
this.ownBranch = flags.branch
this.configBranch = flags.config
this.ansiblePythonInterpreter = flags.interpreter
this.ansibleBinaryPath = flags.ansiblepath
if (flags.verbose) this.verbose = true
this.ensureActiveComposeFile()
this.populateAnsibleHosts()
this.play()
}
}