Skip to content

Commit

Permalink
Some housecleaning and simplification
Browse files Browse the repository at this point in the history
changes:
* removes test/ssh, use vagrant insecure ssh key
* removes "watcher.py.diff" move it inside cts.bash script
* add some comments
  • Loading branch information
ioguix committed Jul 15, 2019
1 parent 23e275d commit 3bb5946
Show file tree
Hide file tree
Showing 11 changed files with 135 additions and 118 deletions.
4 changes: 2 additions & 2 deletions test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ vagrant plugin install vagrant-libvirt
Pacemaker must be able to ssh to the libvirt host with no password using a user able
to `virsh destroy $other_vm`. Here are the steps:

* copy `<PAF>/test/ssh/id_rsa.pub` inside `user@host:~/.ssh/authorized_keys`
* copy `<PAF>/test/provision/id_rsa.pub` inside `user@host:~/.ssh/authorized_keys`
* edit `ssh_login` in the `vagrant.yml` configuration file
* user might need to be in group `libvirt`
* user might need to add `uri_default='qemu:///system'` in its
Expand All @@ -54,7 +54,7 @@ myuser$ mkdir -p "${HOME}/.config/libvirt"
myuser$ echo "uri_default='qemu:///system'" > "${HOME}/.config/libvirt/libvirt.conf"
myuser$ git clone https://github.com/ClusterLabs/PAF.git
myuser$ cd PAF/test
myuser$ cat "ssh/id_rsa.pub" >> "${HOME}/.ssh/authorized_keys"
myuser$ cat "provision/id_rsa.pub" >> "${HOME}/.ssh/authorized_keys"
myuser$ echo "ssh_login: \"$USER\"" >> vagrant.yml
~~~

Expand Down
16 changes: 6 additions & 10 deletions test/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ require 'yaml'
#ENV['VAGRANT_NO_PARALLEL'] = 'yes' # uncomment to forbid parallel execution

pgver = '11' # pg version to use
hapass = 'hapass' # password for sys user hacluster
hapass = 'hapass' # password for sys user hacluster
ssh_login = 'root' # ssh login to connect to the host when fencing a VM.
# put "./ssh/id_rsa.pub" in your "~<ssh_login>/.ssh/authorized_keys"
master_ip = '10.20.30.5' # vIP assigned to master
pg_nodes = 'srv1', 'srv2', 'srv3' # first will be primary
log_node = 'log-sink'
vm_prefix = 'paf_c7'
log_node = 'log-sink' # name of the node receiving logs
vm_prefix = 'paf_c7' # VM prefix in libvrit

if File.file?('vagrant.yml') and ( custom = YAML.load_file('vagrant.yml') )
pgver = custom['pgver'] if custom.has_key?('pgver')
Expand Down Expand Up @@ -51,10 +51,9 @@ Vagrant.configure(2) do |config|
# disable default share
config.vm.synced_folder ".", "/vagrant", disabled: true

# allow root@vm to ssh to ssh_login@network_1
config.vm.synced_folder 'ssh', '/root/.ssh', type: 'rsync',
owner: 'root', group: 'root',
rsync__args: [ "--verbose", "--archive", "--delete", "--copy-links", "--no-perms" ]
config.vm.provision "file", source: '..',
destination: "${HOME}/PAF",
preserve_order: true

# system setup for all ndoes
(pg_nodes + [log_node]).each do |node|
Expand All @@ -66,9 +65,6 @@ Vagrant.configure(2) do |config|
end
end

config.vm.provision "file", source: "provision/watcher.py.diff",
destination: "${HOME}/watcher.py.diff"

# setup rsyslog to collect logs from other node on log-sink
config.vm.define log_node do |conf|
conf.vm.provision 'rsyslog-setup', type: 'shell', path: 'provision/log_sink.bash'
Expand Down
78 changes: 75 additions & 3 deletions test/provision/cts.bash
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ PACKAGES=(

yum install --nogpgcheck --quiet -y -e 0 "${PACKAGES[@]}"

# fix bug in the log watcher.
patch /usr/lib64/python2.7/site-packages/cts/watcher.py ~vagrant/watcher.py.diff

# do not drop any log messages from rsyslog
cat <<'EOF'>/etc/rsyslog.d/rateLimit.conf
$imjournalRatelimitInterval 0
Expand All @@ -34,3 +31,78 @@ RateLimitBurst=0
EOF

systemctl --quiet restart systemd-journald

# fix bug in the log watcher.
cat <<'EOF' | patch /usr/lib64/python2.7/site-packages/cts/watcher.py
*** /tmp/watcher.py.orig 2019-02-07 16:25:32.836265277 +0100
--- /tmp/watcher.py 2019-02-07 16:27:03.296926885 +0100
***************
*** 124,130 ****
self.offset = "EOF"
if host == None:
! host = "localhost"
def __str__(self):
if self.host:
--- 124,130 ----
self.offset = "EOF"
if host == None:
! self.host = "localhost"
def __str__(self):
if self.host:
***************
*** 155,179 ****
class FileObj(SearchObj):
def __init__(self, filename, host=None, name=None):
global has_log_watcher
! SearchObj.__init__(self, filename, host, name)
!
! if host is not None:
! if not host in has_log_watcher:
! global log_watcher
! global log_watcher_bin
! self.debug("Installing %s on %s" % (log_watcher_file, host))
! os.system("cat << END >> %s\n%s\nEND" %(log_watcher_file, log_watcher))
! os.system("chmod 755 %s" %(log_watcher_file))
! self.rsh.cp(log_watcher_file, "root@%s:%s" % (host, log_watcher_bin))
! has_log_watcher[host] = 1
! os.system("rm -f %s" %(log_watcher_file))
! self.harvest()
def async_complete(self, pid, returncode, outLines, errLines):
for line in outLines:
--- 155,176 ----
class FileObj(SearchObj):
def __init__(self, filename, host=None, name=None):
global has_log_watcher
! global log_watcher
! global log_watcher_bin
! SearchObj.__init__(self, filename, host, name)
! self.debug("Installing %s on %s" % (log_watcher_file, self.host))
! os.system("cat << END >> %s\n%s\nEND" %(log_watcher_file, log_watcher))
! os.system("chmod 755 %s" %(log_watcher_file))
! self.rsh.cp(log_watcher_file, "root@%s:%s" % (self.host, log_watcher_bin))
! has_log_watcher[self.host] = 1
! os.system("rm -f %s" %(log_watcher_file))
! self.harvest()
def async_complete(self, pid, returncode, outLines, errLines):
for line in outLines:
EOF

27 changes: 27 additions & 0 deletions test/provision/id_rsa
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEogIBAAKCAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzI
w+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoP
kcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2
hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NO
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M751U/95P9t88EDacDI/Z2OwnuFQHCPDF
llYOUI+SpLJ6/vURRbHSnnn8a/XG+nzedGH5JGqEJNQsz+xT2axM0/W/CRknmGaJ
kda/AoGANWrLCz708y7VYgAtW2Uf1DPOIYMdvo6fxIB5i9ZfISgcJ/bbCUkFrhoH
+vq/5CIWxCPp0f85R4qxxQ5ihxJ0YDQT9Jpx4TMss4PSavPaBH3RXow5Ohe+bYoQ
NE5OgEXk2wVfZczCZpigBKbKZHNYcelXtTt/nP3rsCuGcM4h53s=
-----END RSA PRIVATE KEY-----
1 change: 1 addition & 0 deletions test/provision/id_rsa.pub
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key
25 changes: 24 additions & 1 deletion test/provision/system.bash
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,28 @@ PACKAGES=(

yum install --nogpgcheck --quiet -y -e 0 "${PACKAGES[@]}"

cat <<'EOF' > "/home/vagrant/.ssh/config"
Host *
CheckHostIP no
StrictHostKeyChecking no
EOF

cp "/home/vagrant/PAF/test/provision/id_rsa" "/home/vagrant/.ssh"
cp "/home/vagrant/PAF/test/provision/id_rsa.pub" "/home/vagrant/.ssh"

chown -R "vagrant:" "/home/vagrant/.ssh"
chmod 0700 "/home/vagrant/.ssh"
chmod 0600 "/home/vagrant/.ssh/id_rsa"
chmod 0644 "/home/vagrant/.ssh/id_rsa.pub"
chmod 0600 "/home/vagrant/.ssh/config"
chmod 0600 "/home/vagrant/.ssh/authorized_keys"

cp -R "/home/vagrant/.ssh" "/root"

# force proper permissions on .ssh files
chmod -R 0600 /root/.ssh/
chown -R "root:" "/root/.ssh"
chmod 0700 "/root/.ssh"
chmod 0600 "/root/.ssh/id_rsa"
chmod 0644 "/root/.ssh/id_rsa.pub"
chmod 0600 "/root/.ssh/config"
chmod 0600 "/root/.ssh/authorized_keys"
69 changes: 0 additions & 69 deletions test/provision/watcher.py.diff

This file was deleted.

1 change: 0 additions & 1 deletion test/ssh/authorized_keys

This file was deleted.

4 changes: 0 additions & 4 deletions test/ssh/config

This file was deleted.

27 changes: 0 additions & 27 deletions test/ssh/id_rsa

This file was deleted.

1 change: 0 additions & 1 deletion test/ssh/id_rsa.pub

This file was deleted.

0 comments on commit 3bb5946

Please sign in to comment.