Skip to content

Commit 94b1ce9

Browse files
author
flobee
committed
- Fixes issue if host/node is not configured (tag 1.0.2)
- Adds CHANGELOG - Adds output of executed commands in debug mode - Adds more skel/ files - Uses localhost in demo config - Updates phpdoc
1 parent 8561fee commit 94b1ce9

File tree

5 files changed

+69
-15
lines changed

5 files changed

+69
-15
lines changed

CHANGELOG.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
CHANGELOG - cluster-queue - Dummy Project
2+
============================================================
3+
4+
5+
Possible todos
6+
------------------------------------------------------------
7+
8+
9+
- replace file locations in replacement files?
10+
I.e: 'files' => array('src_REPLACEMENT_KEY '=> 'target_REPLACEMENT_VALUE')...
11+
12+
- Open remote shell while executing the queue
13+
14+
- Interactiv install/ upgrade/ maintainance possibility
15+
16+
- Custom `build/` path including versions eg. date/datetime stamps '2021-12-31/235859'
17+
to collect/archive diffenences? or to commit in VC?
18+
19+
20+
21+
Collected todos for the next release
22+
------------------------------------------------------------
23+
24+
25+
26+
2020-10
27+
------------------------------------------------------------
28+
29+
Init project
30+

skel/testfile.txt

Whitespace-only changes.

src/QueueHelper.php

+19-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class QueueHelper
3434
/**
3535
* Version ID information.
3636
*/
37-
const VERSION = '1.0.1';
37+
const VERSION = '1.0.2';
3838

3939
/**
4040
* Verbose/ debug mode
@@ -372,6 +372,11 @@ private function _runDeploy( string $toHostName, array $list ): void
372372
if ( key( $list ) === 'files' && current( $list ) == true ) {
373373
$pathPrefixSrc = 'build';
374374
$list = array();
375+
376+
if ( ! isset( $this->_configs[$toHostName] ) ) {
377+
throw new Exception( 'Config for "'. $toHostName .'" not found' );
378+
}
379+
375380
foreach ( $this->_configs[$toHostName]['files'] as $file ) {
376381
if ( file_exists( $pathPrefixSrc . '/' . $toHostName . $file ) === false ) {
377382
throw new Exception( 'Src file not found: "' . $file . '"' );
@@ -534,7 +539,7 @@ private function _executeShellCommand( string $command )
534539
return 0;
535540
}
536541

537-
if ($this->_execConfirm && $this->_executeShellCommandConfirm() === false) {
542+
if ( $this->_execConfirm && $this->_executeShellCommandConfirm() === false ) {
538543
return 0;
539544
}
540545

@@ -556,8 +561,19 @@ private function _executeShellCommand( string $command )
556561

557562
return $execCode;
558563
}
564+
else {
565+
$this->_mesgEnd( 'Success', true );
566+
}
559567

560-
$this->_mesgEnd( 'Success', true );
568+
if ( $execMsgs && $this->_debug === true ) {
569+
$this->_mesgStart( 'Remote output found:', 3, true );
570+
$this->_mesgEnd( '', true );
571+
572+
foreach ( $execMsgs as $mesg ) {
573+
$this->_mesgStart( $mesg, 4, true );
574+
$this->_mesgEnd( '', true );
575+
}
576+
}
561577

562578
return 0;
563579
}

src/config/nodeconfigs_demo.php

+13-11
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
return array(
1111
// NODECURRENTPUB/ machine hostname to connect to
1212
// (nodekey = NODECURRENTPUB should be always the same)
13-
'debnode01' => array(
13+
'localhost' => array(
1414

1515
// text replacements/ substitution in config files for
1616

@@ -19,15 +19,16 @@
1919
// what ever you want to do with config templates put in here.
2020

2121
'NODESHAREDIP' => '192.168.169.170', // HA IP for node01 or node02 for the activ one
22-
'NODESDOMAINNAME' => 'debnode01', // or localhost.localdomain or NODECURRENTPUB (def)
23-
'NODECURRENTINT' => 'debnode01int', // internal/ real hostname/ uname -n
24-
'NODECURRENTPUB' => 'debnode01', // key of this config! + hostname to be known in dns/ outside
22+
'NODESDOMAINNAME' => 'localhost', // or localhost.localdomain or NODECURRENTPUB (def)
23+
'NODECURRENTINT' => 'localhostint', // internal/ real hostname/ uname -n
24+
'NODECURRENTPUB' => 'localhost', // key of this config! + hostname to be known in dns/ outside
2525
),
2626

2727
// relevant files for the replacement for this node
2828
// starting in: './skel'
2929
'files' => array(
30-
'/etc/hostname',
30+
//'/testfile.txt', // goes to root: /
31+
'/testfile.txt' => '/tmp/testfile_othername.txt',
3132
),
3233

3334
// Action configs/tokens to queue dependencies
@@ -45,7 +46,7 @@
4546
// ),
4647
//...
4748

48-
'debnode03:deploybuilds' => array(
49+
'localhost:deploybuilds' => array(
4950
'type' => 'deploy', 'value' => array(
5051
// flag to include the values from 'files' from above ('replace' key)
5152
// only once per node config!
@@ -55,7 +56,7 @@
5556
'poskey' => null,
5657
),
5758

58-
'debnode03:deployfirst' => array(
59+
'localhost:deployfirst' => array(
5960
'type' => 'deploy', 'value' => array(
6061
//'/NODECURRENTPUB/etc/mysql/mariadb.cnf' => '/etc/mysql/mariadb.cnf', // must exists in skel/
6162
// 4 the active DB node (needs deploydefaults!)
@@ -66,18 +67,19 @@
6667
'poskey' => null,
6768
),
6869

69-
'debnode01:actionInit' => array(
70+
'localhost:actionInit' => array(
7071
'type' => 'execute', 'value' => array(
7172
//'systemctl disable mysql',
7273
//'systemctl enable drbd.service',
7374
//'#',
74-
//'# Now some information to output...',
75+
'# Now some information to output...',
76+
'echo "TEST ACTION";',
7577
),
7678
'posway' => 'after',
7779
'poskey' => null,
7880
),
7981

80-
'debnode01:actionInitAfterNode2ActionInit' => array(
82+
'localhost:actionInitAfterNode2ActionInit' => array(
8183
'type' => 'execute', 'value' => array(
8284
//'# checking df ....',
8385
//'df -h',
@@ -87,7 +89,7 @@
8789
'posway' => 'after', 'poskey' => null,
8890
),
8991

90-
'debnode01:actionInstallA' => array(
92+
'localhost:actionInstallA' => array(
9193
'type' => 'execute', 'value' => array(
9294
//'#',
9395
//'# Now some information to output...',

src/nodeRunner.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@
124124
}
125125

126126
//
127-
// run
127+
// boot
128128
//
129129

130130
require_once 'vendor/autoload.php';
@@ -142,6 +142,10 @@
142142
/** @var QueueHelper Helper/manager object */
143143
$runner = new QueueHelper( $input, $configNodes, $configsDefault, $logger );
144144

145+
//
146+
// run
147+
//
148+
145149
switch ( $input['action'] ) {
146150
case 'create':
147151
case 'build':
@@ -180,6 +184,7 @@
180184
$runner->run('deploy');
181185
break;
182186

187+
// like deploy for archive
183188
case 'archive':
184189
$runner->configsCreate();
185190

@@ -191,6 +196,7 @@
191196
$runner->run('archive');
192197
break;
193198

199+
// like deploy for actions/excecutions
194200
case 'actions':
195201
case 'excecutions':
196202
$runner->configsCreate();

0 commit comments

Comments
 (0)