-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRexfile
More file actions
146 lines (106 loc) · 3.2 KB
/
Rexfile
File metadata and controls
146 lines (106 loc) · 3.2 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
=head1 NAME
Rexfile - Rex task configuration for CPANTesters
=head1 SYNOPSIS
# TODO
=head1 DESCRIPTION
This file defines all the L<Rex|http://rexify.org> tasks used to deploy
and configure the Kubernetes cluster for the CPANTesters servers.
=head1 SEE ALSO
L<Rex|http://rexify.org>
=cut
use Rex -feature => [ 1.4 ];
use Rex::Commands::Sync;
use Rex::Hardware;
use Term::ReadKey;
use File::Basename qw( basename );
use List::Util qw( uniq );
use HTTP::Tiny;
use JSON::PP;
use YAML::XS qw( Load Dump );
my $JSON = JSON::PP->new->ascii->pretty->canonical;
#######################################################################
# Groups
group servers => qw(
'nact-pdx-001.cpantesters.org',
);
group nodes => qw(
'osl-pdx-[001..002].cpantesters.org',
'lin-sea-[001..003].cpantesters.org',
);
#######################################################################
# Settings
set common_packages_debian => [
# Needed by Flannel
qw( wireguard ),
# Needed by Longhorn
qw( open-iscsi nfs-common cryptsetup ),
];
set common_packages_rocky => [
# Needed by Flannel
qw( wireguard-tools ),
# Needed by Longhorn
qw( targetcli iscsi-initiator-utils ),
];
#######################################################################
# Environments
# TODO: It'd be kinda nice to be able to build a dev Kubernetes cluster
# using Vagrant to test things so we don't have to use production for
# testing.
#######################################################################
# Tasks
=head2 info
Print out the info for the machine, to be used in the CMDB.
=cut
desc 'Show host info';
task info =>
sub {
my %hw_info = Rex::Hardware->get('All');
print Dump(\%hw_info);
};
=head2 prepare
rex prepare
Prepare a machine for a CPAN Testers role by installing common OS packages.
This will also, in the future, install firewalls, update security packages,
and other thing.
This task is run automatically by other prepare tasks like C<prepare_server>
or C<prepare_node>.
=cut
desc 'Prepare the machine for a CPANTesters role by installing OS packages';
task prepare =>
sub {
sudo sub {
Rex::Logger::info( 'Fetching package lists' );
update_package_db;
Rex::Logger::info( "Checking common packages" );
install package => $_ for @{ get 'common_packages' };
Rex::Logger::info( "Adding sudo group to sudoers" );
file '/etc/sudoers.d/sudo-group',
owner => 'root',
group => 'root',
mode => '600', # u+rwx go-rwx
content => '%sudo ALL=(ALL:ALL) ALL',
;
};
};
=head2 prepare_server
rex prepare_server
Prepare the machine to serve as a k3s server.
=cut
desc 'Prepare the machine to be a Kubernetes server (k3s server)';
task prepare_server =>
sub {
sudo sub {
# TODO: Should install k3s and join the cluster as a server
}
};
=head2 prepare_node
rex prepare_node
Prepare the machine to serve as a k3s node.
=cut
desc 'Prepare the machine to be a Kubernetes node (k3s agent)';
task prepare_agent =>
sub {
sudo sub {
# TODO: Should install k3s and join the cluster as a node
}
};