takeltau 0.38.2 → 0.39.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/takeltau/default.yml +5 -3
- data/lib/takeltau/docker/container/cli.rb +2 -0
- data/lib/takeltau/docker/container/lib.rb +1 -4
- data/lib/takeltau/info/status/bar.rb +3 -7
- data/lib/takeltau/info/status/lib.rb +14 -0
- data/lib/takeltau/init/packer/templates/playbooksiteyml.tt +1 -1
- data/lib/takeltau/mutagen/check/daemon.rb +18 -23
- data/lib/takeltau/mutagen/socket/cli.rb +13 -0
- data/lib/takeltau/mutagen/socket/docker.rb +43 -0
- data/lib/takeltau/version +1 -1
- data/lib/takeltau.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80673a82149249c7b16503717deb9938a88f2f8b9a689c6f336a89a5709ed300
|
4
|
+
data.tar.gz: d07eb8a444b0c1e7ccefccdbb26aa9a19d7812f1f339e17a992588cf977ac748
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 169bf5afcc740f79acd671d220b9833305651214b44a1da98ea58b17dcd15b6e72ab118b6bbeedb575ce738bdd9bb3673d40fffaaa2bbabd7734e83512eb13df
|
7
|
+
data.tar.gz: 0ee76be9d69bfb7a702366600ef26af1299a8ee9d4b04bd1da63f7f9123905ec0347d0d39e3fdccf47287a3257f75d94cf8c269af881f6e48198ed6e7f7cd93b
|
data/lib/takeltau/default.yml
CHANGED
@@ -4,7 +4,7 @@ cmd_docker_check_daemon_docker_info: 'docker info'
|
|
4
4
|
cmd_docker_container_check_existing_docker_ps: 'docker ps --filter name=^%{container}$ --quiet'
|
5
5
|
cmd_docker_container_check_network_docker_network: 'docker network ls --quiet --filter name=^%{network}$'
|
6
6
|
cmd_docker_container_check_orphaned_docker_exec: 'docker exec --interactive %{container} ps a'
|
7
|
-
cmd_docker_container_create: 'docker run --detach --env TAKELAGE_PROJECT_BASE_DIR=%{workdir} --env TZ=%{timezone} --hostname %{container} --name %{container} --network %{container} --rm --shm-size %{shmsize} --tty --volume %{
|
7
|
+
cmd_docker_container_create: 'docker run --detach --env TAKELAGE_PROJECT_BASE_DIR=%{workdir} --env TZ=%{timezone} --hostname %{container} --name %{container} --network %{container} --rm --shm-size %{shmsize} --tty --volume %{homedir}:/hostdir --volume %{workdir}:/project %{volume_dev} --workdir /project %{docker_run_options} %{image} %{entrypoint} --gid %{gid} --home %{homedir} --uid %{uid} --username %{username} --extra=%{extra} %{entrypoint_options}'
|
8
8
|
cmd_docker_container_create_network: 'docker network create %{network}'
|
9
9
|
cmd_docker_container_enter_container: 'docker exec --interactive --tty %{container} %{loginpoint} --username %{username}'
|
10
10
|
cmd_docker_container_get_container_name: 'docker ps --filter id=%{container} --format "{{.Names}}"'
|
@@ -46,13 +46,14 @@ cmd_init_lib_git_commit_initial: 'git commit -m "Initial commit"'
|
|
46
46
|
cmd_init_lib_hg_clone: 'bash hgclone'
|
47
47
|
cmd_mutagen: 'mutagen'
|
48
48
|
cmd_mutagen_check_daemon_host_connection: 'mutagen forward list --label-selector="%{hostlabel}"'
|
49
|
-
|
49
|
+
cmd_mutagen_check_daemon_start_daemon: 'mutagen daemon start'
|
50
50
|
cmd_mutagen_forward_socket_create: 'mutagen forward create --name=%{socketname} --label=%{hostlabel} --label=%{takellabel} docker://%{username}@%{container}:unix:%{containersock} unix:%{hostsock}'
|
51
|
+
cmd_mutagen_forward_socket_docker: 'mutagen forward create --name=%{socketname} --label=%{hostlabel} --label=%{takellabel} --socket-group-source=docker --socket-permission-mode=0660 docker://root@%{container}:unix:/var/run/docker.sock unix:%{hostsock}'
|
51
52
|
cmd_mutagen_forward_socket_check: 'mutagen forward list %{socketname}'
|
52
53
|
cmd_mutagen_forward_socket_terminate: 'mutagen forward terminate %{socketname}'
|
53
54
|
cmd_mutagen_forward_socket_remove: 'rm -f ~/.mutagen/daemon/*'
|
54
55
|
cmd_mutagen_forward_socket_list: 'mutagen forward list --label-selector="%{takellabel}"'
|
55
|
-
docker_debug: 'ansible/roles/
|
56
|
+
docker_debug: 'ansible/roles/takel_takelage/files/takelscripts'
|
56
57
|
docker_entrypoint_extra: '.config/gcloud'
|
57
58
|
docker_entrypoint_options: ''
|
58
59
|
docker_registry: 'https://registry.hub.docker.com'
|
@@ -67,6 +68,7 @@ info_project_private: 'private/project.yml'
|
|
67
68
|
login_wait_for_sockets: '0'
|
68
69
|
mutagen_socket_path_mutagen_container: '~/.mutagen/daemon/daemon.sock'
|
69
70
|
mutagen_socket_path_mutagen_host: '~/.mutagen/daemon/daemon.sock'
|
71
|
+
mutagen_socket_path_docker_host: '/var/run/docker.sock'
|
70
72
|
mutagen_socket_path_gpg_container: '~/.gnupg/S.gpg-agent'
|
71
73
|
mutagen_socket_path_gpg_host: '~/.gnupg/S.gpg-agent'
|
72
74
|
mutagen_socket_path_ssh_container: '~/.gnupg/S.gpg-agent.ssh'
|
@@ -22,6 +22,7 @@ module Takeltau
|
|
22
22
|
include MutagenCheckDaemon
|
23
23
|
include MutagenSocketCheck
|
24
24
|
include MutagenSocketCreate
|
25
|
+
include MutagenSocketDocker
|
25
26
|
include MutagenSocketTerminate
|
26
27
|
|
27
28
|
# Initialize docker container
|
@@ -40,6 +41,7 @@ module Takeltau
|
|
40
41
|
@hostname = _docker_container_lib_hostname
|
41
42
|
@hostlabel = "hostname=#{@hostname}"
|
42
43
|
@takellabel = config.active['mutagen_socket_takelage_label']
|
44
|
+
@dockersock_host = config.active['mutagen_socket_path_docker_host']
|
43
45
|
@mutagensock_container = config.active['mutagen_socket_path_mutagen_container']
|
44
46
|
@mutagensock_host = config.active['mutagen_socket_path_mutagen_host']
|
45
47
|
@gpgsock_container = config.active['mutagen_socket_path_gpg_container']
|
@@ -10,6 +10,7 @@ module DockerContainerLib
|
|
10
10
|
def _docker_container_lib_start_sockets
|
11
11
|
return false unless mutagen_check_daemon
|
12
12
|
|
13
|
+
mutagen_socket_docker @dockersock_host
|
13
14
|
mutagen_socket_create 'mutagen', @mutagensock_container, @mutagensock_host
|
14
15
|
mutagen_socket_create 'gpg', @gpgsock_container, @gpgsock_host
|
15
16
|
mutagen_socket_create 'ssh', @sshsock_container, @sshsock_host
|
@@ -91,7 +92,6 @@ module DockerContainerLib
|
|
91
92
|
config.active['cmd_docker_container_create'],
|
92
93
|
container: container,
|
93
94
|
docker_run_options: config.active['docker_run_options'],
|
94
|
-
dockersock: '/var/run/docker.sock',
|
95
95
|
entrypoint: entrypoint,
|
96
96
|
entrypoint_options: config.active['docker_entrypoint_options'],
|
97
97
|
extra: config.active['docker_entrypoint_extra'],
|
@@ -122,7 +122,6 @@ module DockerContainerLib
|
|
122
122
|
end
|
123
123
|
|
124
124
|
log.debug 'We are inside a takelage container'
|
125
|
-
|
126
125
|
true
|
127
126
|
end
|
128
127
|
|
@@ -145,9 +144,7 @@ module DockerContainerLib
|
|
145
144
|
)
|
146
145
|
|
147
146
|
name = (run cmd_get_container_name_by_id).chomp
|
148
|
-
|
149
147
|
log.debug "Container #{container} has name \"#{name}\""
|
150
|
-
|
151
148
|
name
|
152
149
|
end
|
153
150
|
|
@@ -29,14 +29,10 @@ module InfoStatusBar
|
|
29
29
|
|
30
30
|
# Add takelage version info to bar.
|
31
31
|
def _info_status_bar_takelage
|
32
|
-
|
33
|
-
unless
|
34
|
-
@bar_status = false
|
35
|
-
return false
|
36
|
-
end
|
32
|
+
# Check if we are inside a takelage docker container
|
33
|
+
return unless _docker_container_lib_check_matrjoschka
|
37
34
|
|
38
|
-
|
39
|
-
@bar_list << "#{config.active['docker_repo']}: #{@content_file.chomp.green}"
|
35
|
+
@bar_list << _info_status_lib_get_channel_and_version
|
40
36
|
end
|
41
37
|
|
42
38
|
# Add tau version info to bar.
|
@@ -43,4 +43,18 @@ module InfoStatusLib
|
|
43
43
|
)
|
44
44
|
try cmd_git_key_available
|
45
45
|
end
|
46
|
+
|
47
|
+
# Get takelage environment string
|
48
|
+
def _info_status_lib_get_channel_and_version
|
49
|
+
takelage_version_file = '/etc/takelage_version'
|
50
|
+
return '' unless _file_exists? takelage_version_file
|
51
|
+
|
52
|
+
_file_read takelage_version_file
|
53
|
+
|
54
|
+
channel = config.active['docker_repo']
|
55
|
+
version = @content_file.chomp
|
56
|
+
|
57
|
+
log.debug "#{channel}: #{version.green}"
|
58
|
+
"#{channel}: #{version.green}"
|
59
|
+
end
|
46
60
|
end
|
@@ -5,17 +5,21 @@ module MutagenCheckDaemon
|
|
5
5
|
# Backend method for mutagen check daemon.
|
6
6
|
# @return [Boolean] is mutagen available?
|
7
7
|
# rubocop:disable Metrics/MethodLength
|
8
|
+
# rubocop:disable Metrics/AbcSize
|
8
9
|
def mutagen_check_daemon
|
9
10
|
return true if @mutagen_daemon_available
|
10
11
|
|
11
12
|
log.debug 'Check mutagen status'
|
12
13
|
|
13
|
-
|
14
|
+
unless _mutagen_check_daemon_start
|
15
|
+
log.error 'The mutagen daemon cannot be started'
|
16
|
+
return false
|
17
|
+
end
|
14
18
|
|
15
|
-
# are we
|
19
|
+
# are we inside a takelage container?
|
16
20
|
unless _docker_container_lib_check_matrjoschka
|
17
|
-
unless
|
18
|
-
log.error 'The mutagen
|
21
|
+
unless _file_exists? config.active['mutagen_socket_path_mutagen_host']
|
22
|
+
log.error 'The mutagen socket path on the host is not available'
|
19
23
|
return false
|
20
24
|
end
|
21
25
|
|
@@ -29,6 +33,11 @@ module MutagenCheckDaemon
|
|
29
33
|
return false
|
30
34
|
end
|
31
35
|
|
36
|
+
unless _file_exists? config.active['mutagen_socket_path_mutagen_container']
|
37
|
+
log.error 'The mutagen socket path in the container is not available'
|
38
|
+
return false
|
39
|
+
end
|
40
|
+
|
32
41
|
log.debug 'The mutagen daemon is available'
|
33
42
|
@mutagen_daemon_available = true
|
34
43
|
true
|
@@ -37,21 +46,6 @@ module MutagenCheckDaemon
|
|
37
46
|
|
38
47
|
private
|
39
48
|
|
40
|
-
# Check mutagen prerequisites
|
41
|
-
def _mutagen_check_check_prerequisites
|
42
|
-
unless _file_exists? config.active['mutagen_socket_path_mutagen_container']
|
43
|
-
log.error 'The mutagen socket path in the container is not available'
|
44
|
-
return false
|
45
|
-
end
|
46
|
-
|
47
|
-
unless _file_exists? config.active['mutagen_socket_path_mutagen_host']
|
48
|
-
log.error 'The mutagen socket path on the host is not available'
|
49
|
-
return false
|
50
|
-
end
|
51
|
-
|
52
|
-
command_available_else_error? config.active['cmd_mutagen']
|
53
|
-
end
|
54
|
-
|
55
49
|
# Check mutagen host connection
|
56
50
|
# rubocop:disable Metrics/MethodLength
|
57
51
|
def _mutagen_check_daemon_host_connection
|
@@ -74,11 +68,12 @@ module MutagenCheckDaemon
|
|
74
68
|
|
75
69
|
true
|
76
70
|
end
|
71
|
+
# rubocop:enable Metrics/AbcSize
|
77
72
|
# rubocop:enable Metrics/MethodLength
|
78
73
|
|
79
|
-
#
|
80
|
-
def
|
81
|
-
|
82
|
-
|
74
|
+
# Start mutagen daemon
|
75
|
+
def _mutagen_check_daemon_start
|
76
|
+
start = try config.active['cmd_mutagen_check_daemon_start_daemon']
|
77
|
+
start.exitstatus.zero?
|
83
78
|
end
|
84
79
|
end
|
@@ -17,6 +17,7 @@ module Takeltau
|
|
17
17
|
include MutagenCheckDaemon
|
18
18
|
include MutagenSocketCheck
|
19
19
|
include MutagenSocketCreate
|
20
|
+
include MutagenSocketDocker
|
20
21
|
include MutagenSocketList
|
21
22
|
include MutagenSocketTidy
|
22
23
|
include MutagenSocketTerminate
|
@@ -61,6 +62,18 @@ module Takeltau
|
|
61
62
|
exit mutagen_socket_create name, containersock, hostsock
|
62
63
|
end
|
63
64
|
|
65
|
+
#
|
66
|
+
# mutagen socket create
|
67
|
+
#
|
68
|
+
desc 'docker [OUT]', 'Create a mutagen docker socket [OUT] of the container'
|
69
|
+
long_desc <<-LONGDESC.gsub("\n", "\x5")
|
70
|
+
Create a mutagen docker socket [OUT] of the container
|
71
|
+
LONGDESC
|
72
|
+
# Create a mutagen docker socket [OUT] of the container.
|
73
|
+
def docker(hostsock)
|
74
|
+
exit mutagen_socket_docker hostsock
|
75
|
+
end
|
76
|
+
|
64
77
|
#
|
65
78
|
# mutagen socket list
|
66
79
|
#
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# tau mutagen socket docker
|
4
|
+
module MutagenSocketDocker
|
5
|
+
# Backend method for mutagen socket docker.
|
6
|
+
# rubocop:disable Metrics/MethodLength
|
7
|
+
def mutagen_socket_docker(hostsock)
|
8
|
+
# See DockerContainerLib::_docker_container_lib_hostname
|
9
|
+
socketname = "#{@hostname[-11..-1]}-docker"
|
10
|
+
log.debug "Create the mutagen docker socket \"#{socketname}\" in the container " \
|
11
|
+
"pointing to the host at \"#{hostsock}\""
|
12
|
+
|
13
|
+
return false unless mutagen_check_daemon
|
14
|
+
|
15
|
+
return false if mutagen_socket_check socketname
|
16
|
+
|
17
|
+
socket_created = _mutagen_socket_docker_socket(socketname, hostsock)
|
18
|
+
|
19
|
+
unless socket_created.include? 'Created session'
|
20
|
+
log.debug "Unable to create mutagen docker socket \"#{socketname}\""
|
21
|
+
return false
|
22
|
+
end
|
23
|
+
|
24
|
+
log.debug "Created the mutagen docker socket \"#{socketname}\""
|
25
|
+
true
|
26
|
+
end
|
27
|
+
# rubocop:enable Metrics/MethodLength
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
# Get git branch.
|
32
|
+
def _mutagen_socket_docker_socket(socketname, hostsock)
|
33
|
+
cmd_create_socket = format(
|
34
|
+
config.active['cmd_mutagen_forward_socket_docker'],
|
35
|
+
socketname: socketname,
|
36
|
+
hostsock: hostsock,
|
37
|
+
container: @hostname,
|
38
|
+
hostlabel: @hostlabel,
|
39
|
+
takellabel: @takellabel
|
40
|
+
)
|
41
|
+
run cmd_create_socket
|
42
|
+
end
|
43
|
+
end
|
data/lib/takeltau/version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.39.11
|
data/lib/takeltau.rb
CHANGED
@@ -40,6 +40,7 @@ require_relative 'takeltau/init/cli'
|
|
40
40
|
require_relative 'takeltau/mutagen/check/daemon'
|
41
41
|
require_relative 'takeltau/mutagen/socket/check'
|
42
42
|
require_relative 'takeltau/mutagen/socket/create'
|
43
|
+
require_relative 'takeltau/mutagen/socket/docker'
|
43
44
|
require_relative 'takeltau/mutagen/socket/terminate'
|
44
45
|
require_relative 'takeltau/mutagen/socket/tidy'
|
45
46
|
require_relative 'takeltau/docker/check/daemon'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: takeltau
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.39.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takelwerk
|
@@ -272,6 +272,7 @@ files:
|
|
272
272
|
- lib/takeltau/mutagen/socket/check.rb
|
273
273
|
- lib/takeltau/mutagen/socket/cli.rb
|
274
274
|
- lib/takeltau/mutagen/socket/create.rb
|
275
|
+
- lib/takeltau/mutagen/socket/docker.rb
|
275
276
|
- lib/takeltau/mutagen/socket/list.rb
|
276
277
|
- lib/takeltau/mutagen/socket/terminate.rb
|
277
278
|
- lib/takeltau/mutagen/socket/tidy.rb
|