Vagrant 1.8.5 – public key problem

If you like to create with kitchen a new Vagrant instance with the Vagrant version 1.8.5 you get the following problem:

           default: Vagrant insecure key detected. Vagrant will automatically replace
           default: this with a newly generated keypair for better security.
           default:
           default: Inserting generated public key within guest...
           default: Removing insecure key from the guest if it's present...
           default: Key inserted! Disconnecting and reconnecting using new SSH key...
           default: Warning: Authentication failure. Retrying...
           default: Warning: Authentication failure. Retrying...
           default: Warning: Authentication failure. Retrying...
           default: Warning: Authentication failure. Retrying...
           default: Warning: Authentication failure. Retrying...
           default: Warning: Authentication failure. Retrying...
           default: Warning: Authentication failure. Retrying...
           default: Warning: Authentication failure. Retrying...

To fix this, you should create this file:

vi .vagrant.d/Vagrantfile

With the content:

Vagrant.configure("2") do |config|
  config.ssh.insert_key = false
end

rsync status with lsof

To see the status from rsync, you can use lsof:

lsof -ad3-999 -c rsync

Output:

COMMAND  PID USER   FD   TYPE             DEVICE SIZE/OFF       NODE NAME
rsync   8097 root    3r   REG             252,17   404832 7559983121 /srv/data/safematix
rsync   8097 root    4u  unix 0xffff8806f4447080      0t0      85225 type=STREAM
rsync   8097 root    5u  unix 0xffff8806f4444ec0      0t0      85226 type=STREAM
rsync   8098 root    3u  unix 0xffff880738502580      0t0      77431 type=STREAM
rsync   8099 root    4u  unix 0xffff880738500b40      0t0      77432 type=STREAM

Move logical Volumes to other volume group and remove the physical volume.

At the beginning, it look like:

~# lvs
  LV         VG         Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  log        system     -wi-ao----  1.86g
  root       system     -wi-ao----  2.79g
  swap       system     -wi-ao----  1.86g
  tmp        system     -wi-ao----  1.86g
  usr        system     -wi-ao----  1.86g
  var        system     -wi-ao---- 31.72g
  testlv     systemtest -wi-------  5.00g
  testlv2    systemtest -wi------- 20.00g
~# pvs
  PV         VG         Fmt  Attr PSize   PFree
  /dev/md0   systemtest lvm2 a--  884.63g 859.63g
  /dev/sdk3  system     lvm2 a--  147.61g 105.66g

Now we begin to merge the two volume groups to one.

vgsplit -n systemtest/testlv systemtest system

Now it look like:

~# pvs
  PV         VG     Fmt  Attr PSize   PFree
  /dev/md0   system lvm2 a--  884.63g 859.63g
  /dev/sdk3  system lvm2 a--  147.61g 105.66g
~# lvs
  LV         VG         Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  log        system     -wi-ao----  1.86g
  root       system     -wi-ao----  2.79g
  swap       system     -wi-ao----  1.86g
  tmp        system     -wi-ao----  1.86g
  usr        system     -wi-ao----  1.86g
  var        system     -wi-ao---- 31.72g
  testlv     system     -wi-------  5.00g
  testlv2    system     -wi------- 20.00g

Now we want to remove md0, but before we must move the data to the other physical volume.

~# pvmove /dev/md0
  /dev/md0: Moved: 0.0%
  /dev/md0: Moved: 5.5%
  /dev/md0: Moved: 10.6%
  /dev/md0: Moved: 14.1%
  /dev/md0: Moved: 17.6%
  /dev/md0: Moved: 21.8%
  /dev/md0: Moved: 25.3%
  /dev/md0: Moved: 28.9%
  /dev/md0: Moved: 32.4%
  /dev/md0: Moved: 36.2%
  /dev/md0: Moved: 39.8%
  /dev/md0: Moved: 43.6%
  /dev/md0: Moved: 47.4%
  /dev/md0: Moved: 50.7%
  /dev/md0: Moved: 54.6%
  /dev/md0: Moved: 58.1%
  /dev/md0: Moved: 62.0%
  /dev/md0: Moved: 65.9%
  /dev/md0: Moved: 69.1%
  /dev/md0: Moved: 72.9%
  /dev/md0: Moved: 76.9%
  /dev/md0: Moved: 80.0%
  /dev/md0: Moved: 83.7%
  /dev/md0: Moved: 87.2%
  /dev/md0: Moved: 90.8%
  /dev/md0: Moved: 95.0%
  /dev/md0: Moved: 98.6%
  /dev/md0: Moved: 100.0%

Now we can remove the md0 from the system volume group.

~# vgreduce system /dev/md0
  Removed "/dev/md0" from volume group "system"

lxd shared directory

To share the data to a LXD container, you must set the UID and GID to 100000. In the container it will be the id from root (0).

chown -R 100000:100000 /srv/shared

Now you can connect the shared folder:

lxc config device add mycontainer shared disk path=/srv/shared source=/srv/shared

gem mirror – gemirro

Gemirro is a Ruby application that makes it easy way to create your own RubyGems mirror without having to push or write all gem you wanted in a configuration file. It does mirroring without any authentication and you can add your private gems in the gems directory. More, to mirroring a source, you only need to start the server, and gems will automaticly be downloaded when needed.

Gemirro will start on port 2000. I should proxy it via nginx.

Install the gem gemirro:

gem install gemirro

Create your mirror:

gemirro init /srv/mirror/gems/

Create a gemirro index:

gemirro index

Start the server:

gemirro server --start

Show the status:

gemirro server --status

Stop the server:

gemirro server --stop

Start the server with a http/s proxy:

https_proxy="https://proxy.safematix.com:8080" gemirro server --start

Github gemirro

OpenBSD chef client

OpenBSD chef client

If you like to install chef client on OpenBSD, you must install ruby on it:

pkg_add ruby
quirks-2.114 signed on 2015-08-09T11:57:52Z
Ambiguous: choose package for ruby
a       0: 
        1: ruby-1.8.7.374p4
        2: ruby-1.9.3.551p2
        3: ruby-2.0.0.645p0
        4: ruby-2.1.6p0
        5: ruby-2.2.2p0
Your choice: 5
ruby-2.2.2p0:libffi-3.1p0: ok
ruby-2.2.2p0:libyaml-0.1.6p1: ok
ruby-2.2.2p0:gmp-5.0.2p3: ok
ruby-2.2.2p0: ok
--- +ruby-2.2.2p0 -------------------
If you want to use this package as your default system ruby, as root
create symbolic links like so (overwriting any previous default):
 ln -sf /usr/local/bin/ruby22 /usr/local/bin/ruby
 ln -sf /usr/local/bin/erb22 /usr/local/bin/erb
 ln -sf /usr/local/bin/irb22 /usr/local/bin/irb
 ln -sf /usr/local/bin/rdoc22 /usr/local/bin/rdoc
 ln -sf /usr/local/bin/ri22 /usr/local/bin/ri
 ln -sf /usr/local/bin/rake22 /usr/local/bin/rake
 ln -sf /usr/local/bin/gem22 /usr/local/bin/gem

Now install chef client:

gem install chef

Removing lost physical volumes from a volume group

Removing lost physical volumes from a volume group

LVM
LVM

If you get this crazy message and you are lucky that all data are on the other disk, then you can use this steps.

Get the status of the physical volumes:

pvs
  Couldn't find device with uuid Lxx4Mu-37Ie-3Y2d-kXJe-hd6v-ynUI-pa1zxc.
  PV             VG        Fmt  Attr PSize   PFree  
  /dev/sda2      vg_system lvm2 a--u  99.61g   2.93g
  unknown device vg_system lvm2 a-mu 100.00g 100.00g

Get the status of the volume groups:

vgs
  Couldn't find device with uuid Lxx4Mu-37Ie-3Y2d-kXJe-hd6v-ynUI-pa1zxc.
  VG        #PV #LV #SN Attr   VSize   VFree  
  vg_system   2   5   0 wz-pn- 199.60g 102.92g

Get the status of the logical volumes and the devices:

lvs -a -o +devices
  Couldn't find device with uuid Lxx4Mu-37Ie-3Y2d-kXJe-hd6v-ynUI-pa1zxc.
  LV      VG        Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert Devices         
  lv_home vg_system -wi-ao---- 53.71g                                                     /dev/sda2(0)    
  lv_root vg_system -wi-ao---- 14.65g                                                     /dev/sda2(13750)
  lv_swap vg_system -wi-ao----  3.91g                                                     /dev/sda2(17500)
  lv_tmp  vg_system -wi-ao----  4.88g                                                     /dev/sda2(18500)
  lv_var  vg_system -wi-ao---- 19.53g                                                     /dev/sda2(19750)

Now you can use the test option to try to remove the unknown device from the volume group:

vgreduce --test vg_system --removemissing
  TEST MODE: Metadata will NOT be updated and volumes will not be (de)activated.
  Couldn't find device with uuid Lxx4Mu-37Ie-3Y2d-kXJe-hd6v-ynUI-pa1zxc.
  Wrote out consistent volume group vg_system

Now remove it and write the change:

vgreduce vg_system --removemissing
  Couldn't find device with uuid Lxx4Mu-37Ie-3Y2d-kXJe-hd6v-ynUI-pa1zxc.
  Wrote out consistent volume group vg_system

You can see the error message is away:

root@tvhvma-psz111: [~]# vgs
  VG        #PV #LV #SN Attr   VSize  VFree
  vg_system   1   5   0 wz--n- 99.61g 2.93g

Now you can add the device again.

Add the physical volume:

pvcreate /dev/sdb1 
  Physical volume "/dev/sdb1" successfully created

Show the status from the physical volumes:

pvs
  PV         VG        Fmt  Attr PSize   PFree  
  /dev/sda2  vg_system lvm2 a--u  99.61g   2.93g
  /dev/sdb1            lvm2 ---- 100.00g 100.00g

Show the status from the volume group:

vgs
  VG        #PV #LV #SN Attr   VSize  VFree
  vg_system   1   5   0 wz--n- 99.61g 2.93g

Add the physical volume to the volume group:

vgextend vg_system /dev/sdb1
  Volume group "vg_system" successfully extended

Now you can see the aktiv physical volume:

pvs
  PV         VG        Fmt  Attr PSize   PFree  
  /dev/sda2  vg_system lvm2 a--u  99.61g   2.93g
  /dev/sdb1  vg_system lvm2 a--u 100.00g 100.00g

Show the status from the group and you can see now is more space.

vgs
  VG        #PV #LV #SN Attr   VSize   VFree  
  vg_system   2   5   0 wz--n- 199.60g 102.92g

Linux, BSD, Unix and Security tips