LoginSignup
1
0

More than 5 years have passed since last update.

Itamae | vagrant オプションで Vagrantにトイレを設置 #devops #itamae

Last updated at Posted at 2014-10-14

Itamae | vagrant オプションで Vagrantにトイレを設置 #devops #itamae

概要

プロビジョニングツール Itamae

vagrant オプションでVagrantで作成した環境へのプロビジョニングを行います。
toilet コマンドのインストールします。

※toilet コマンドについては下記リンク参照
http://www.tecmint.com/20-funny-commands-of-linux-or-linux-is-fun-in-terminal/

試行

前提

動作確認に使用した Vagrantfile

# -*- mode: ruby -*-
# vi: set ft=ruby :

VAGRANTFILE_API_VERSION = "2"

$script = <<SCRIPT
sudo apt-get upgrade -y
sudo apt-get update -y
SCRIPT

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.define "itamae-target" do |web|
    web.vm.provider :virtualbox do |vb|
      vb.name = "itamae_target"
    end
    web.vm.hostname = "itamae-target"
    web.vm.box = "precise64"
    web.vm.provision "shell", inline: $script
    web.vm.network :private_network, ip: "192.168.33.99"
  end
end

仕様

  • toilet をインストールするだけのレシピを利用。
package "toilet" do
  action :install
end
  • Vagrant の VM名は itamae_target
  • user は vagrant

実行

# ssh コマンドでローカル環境からプロビジョニング実行
$ vagrant ssh-config --host itamae-target
Host itamae-target
  HostName 127.0.0.1
  User vagrant
  Port 2222
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile /path/to/your/key/insecure_private_key
  IdentitiesOnly yes
  LogLevel FATAL
$ itamae ssh --vagrant -h itamae-target recipe.rb
 INFO : Starting Itamae...
 INFO : Recipe: /path/to/your/vagrant_home/itamae_target/recipe.rb
 INFO :    package[toilet]
 INFO :       action: install
 INFO :          installed will change from 'false' to 'true'

$ vagrant ssh
$ which toilet
/usr/bin/toilet
$ toilet -v
TOIlet Copyright 2006 Sam Hocevar
Internet: <sam@hocevar.net> Version: 0.2, date:

TOIlet, along with the various TOIlet fonts and documentation, may be
freely copied and distributed.

If you use TOIlet, please send an e-mail message to <sam@hocevar.net>.

The latest version of TOIlet is available from the web site,
        http://libcaca.zoy.org/toilet.html

Usage: toilet [ -hkostvSW ] [ -d fontdirectory ]
              [ -f fontfile ] [ -F filter ] [ -w outputwidth ]
              [ -I infocode ] [ -E format ] [ message ]

$ toilet "Itamae" -F gay

 mmmmm    m
   #    mm#mm   mmm   mmmmm   mmm    mmm
   #      #    "   #  # # #  "   #  #"  #
   #      #    m"""#  # # #  m"""#  #""""
 mm#mm    "mm  "mm"#  # # #  "mm"#  "#mm"

itamae_toilet_gay.png

コードリーディング

vagrant オプションは、内部で下記のコマンドを実行しています

`vagrant ssh-config #{opts[:host]} > #{config.path}`

opts[:hosts] は --host (-h) オプションの指定内容。
config は一時ファイルです。

参照

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0