Skip to content

Commit

Permalink
more safe autocorrections
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasAud committed Jan 17, 2024
1 parent 18566db commit 84999d1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 40 deletions.
28 changes: 0 additions & 28 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,6 @@
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 6
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: space, no_space
Layout/LineContinuationSpacing:
Exclude:
- 'tasks/docker.rb'

# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: aligned, indented
Layout/LineEndStringConcatenationIndentation:
Exclude:
- 'tasks/docker.rb'

# Offense count: 13
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
Metrics/AbcSize:
Expand Down Expand Up @@ -117,21 +101,9 @@ Style/MixinUsage:
- 'tasks/docker_exp.rb'
- 'tasks/vagrant.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Style/NegatedIfElseCondition:
Exclude:
- 'tasks/docker.rb'

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: Methods.
Style/RedundantArgument:
Exclude:
- 'tasks/update_node_pp.rb'

# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
Style/RedundantStringEscape:
Exclude:
- 'tasks/vagrant.rb'
22 changes: 11 additions & 11 deletions tasks/docker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ def install_ssh_components(distro, version, container)
# sometimes the redhat 6 variant containers like to eat their rpmdb, leading to
# issues with "rpmdb: unable to join the environment" errors
# This "fix" is from https://www.srv24x7.com/criticalyum-main-error-rpmdb-open-failed/
run_local_command("docker exec #{container} bash -exc \"rm -f /var/lib/rpm/__db*; "\
'db_verify /var/lib/rpm/Packages; '\
'rpm --rebuilddb; '\
'yum clean all; '\
'yum install -y sudo openssh-server openssh-clients"')
run_local_command("docker exec #{container} bash -exc \"rm -f /var/lib/rpm/__db*; " \
'db_verify /var/lib/rpm/Packages; ' \
'rpm --rebuilddb; ' \
'yum clean all; ' \
'yum install -y sudo openssh-server openssh-clients"')
else
# If systemd is running for init, ensure systemd has finished starting up before proceeding:
check_init_cmd = 'if [[ "$(readlink /proc/1/exe)" == "/usr/lib/systemd/systemd" ]]; then '\
'count=0 ; while ! [[ "$(systemctl is-system-running)" =~ ^running|degraded$ && $count > 20 ]]; '\
'do sleep 0.1 ; count=$((count+1)) ; done ; fi'
check_init_cmd = 'if [[ "$(readlink /proc/1/exe)" == "/usr/lib/systemd/systemd" ]]; then ' \
'count=0 ; while ! [[ "$(systemctl is-system-running)" =~ ^running|degraded$ && $count > 20 ]]; ' \
'do sleep 0.1 ; count=$((count+1)) ; done ; fi'
run_local_command("docker exec #{container} bash -c '#{check_init_cmd}'")
run_local_command("docker exec #{container} yum install -y sudo openssh-server openssh-clients")
end
Expand Down Expand Up @@ -74,10 +74,10 @@ def fix_ssh(distro, version, container)
# https://bugzilla.redhat.com/show_bug.cgi?id=1728777
run_local_command("docker exec #{container} sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd") if distro =~ %r{redhat|centos} && version =~ %r{^7}

if !%r{^(7|8|9|2)}.match?(version)
run_local_command("docker exec #{container} service sshd restart")
else
if %r{^(7|8|9|2)}.match?(version)
run_local_command("docker exec #{container} /usr/sbin/sshd")
else
run_local_command("docker exec #{container} service sshd restart")
end
when %r{sles}
run_local_command("docker exec #{container} /usr/sbin/sshd")
Expand Down
2 changes: 1 addition & 1 deletion tasks/vagrant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def generate_vagrantfile(file_path, platform, enable_synced_folder, provider, cp
''
end
vf = <<~VF
Vagrant.configure(\"2\") do |config|
Vagrant.configure("2") do |config|
config.vm.box = '#{platform}'
config.vm.boot_timeout = 600
config.ssh.insert_key = false
Expand Down

0 comments on commit 84999d1

Please sign in to comment.