LoginSignup
7
2

More than 3 years have passed since last update.

AnsibleでCentOS7へジョークプログラムをインストールする

Last updated at Posted at 2018-12-01

はじめに

こちらはAnsible Advent Calendar 2018 2日目の記事です。

この記事ではAnsibleを利用したジョークプログラムのインストール方法を紹介します。インストールプログラムについてはこちらの記事を参考にさせて頂きました。

2日目の記事と言う事でAnsible Playbookの簡単な使い方のサンプル集になってます。

想定環境

  • OS / CentOS7
  • Ansibleのバージョン / 2.7以降

検証環境

tomonorimatsumura/centos7-ansible - Docker Hub のイメージで動作確認してます。

インストールするプログラム

ターミナルに水槽を出力するプログラムです。

タイトルなし.gif

作業時間等を計測するタイマーコマンドです。

beer-mug.gif

ターミナルに映画Matrixのオープニング風の画面を出力します。

cmatrix.gif

牛などが喋ります。

cowsay.gif

キュアエンジニアのためのコマンドラインツールです。

cure.gif

英語の「迷言」をランダムに出力します。

fortune.gif

Nyancatをターミナル上で走らせます。

nyancat.gif

ゲームが開始されます。

pong.gif

汽車が走ります。

sl.gif

プログラムをすぐに試したい

上記のプログラムをインストールしたDockerイメージを作成しました。

tomonorimatsumura/centos7-joke-programs - Docker Hub

Dockerがインストールされている端末上で以下のコマンドを入力するとすぐに試すことができます。 Dockerイメージは2GB程になりますので利用する前にストレージの空き容量に注意してください。

docker run -it tomonorimatsumura/centos7-joke-programs /bin/bash

ASCIIQuarium

インストール

ansible-joke-programs/asciiquarium | GitHub からPlaybookを取得し ansible-playbook コマンドをroot権限で実行します。

git clone https://github.com/ansible-joke-programs/asciiquarium.git
cd asciiquarium
ansible-galaxy install -r roles/requirements.yml -p /roles/
ansible-playbook -i localhost, -c local install.yml

ASCIIQuariumを実行する

asciiquarium

#control + c で終了

beer-mug

インストール方法

工事中 からPlaybookを取得し ansible-playbook コマンドをroot権限で実行します。

工事中

beer-mugを実行する

beer-mug init
beer-mug start
# 何か作業をする
beer-mug end

#beer-mugが稼働しているかどうか調べる
beer-mug status

CMatrix

インストール

ansible-joke-programs/cmatrix からPlaybookを取得し ansible-playbook コマンドをroot権限で実行します。

git clone https://github.com/ansible-joke-programs/cmatrix.git
cd cmatrix
ansible-galaxy install -r roles/requirements.yml -p /roles/
ansible-playbook -i localhost, -c local install.yml

CMatrixを実行する

cmatrix

# q で終了

コマンドオプション

オプション 効果
-a Asynchronous scroll
-b Bold characters on
-B All bold characters (overrides -b)
-f Force the linux $TERM type to be on
-l Linux mode (uses matrix console font)
-o Use old-style scrolling
-h Print usage and exit
-n No bold characters (overrides -b and -B, default)
-s "Screensaver" mode, exits on first keystroke
-x X window mode, use if your xterm is using mtx.pcf
-V Print version information and exit
-u delay (0 - 10, default 4): Screen update delay
-C [color] Use this color for matrix (default green)
-r rainbow mode

cowsay

インストール方法

ansible-joke-programs/cowsay | GitHub からPlaybookを取得し ansible-playbook コマンドをroot権限で実行します。

git clone https://github.com/ansible-joke-programs/cowsay.git
cd cowsay
ansible-galaxy install -r roles/requirements.yml -p /roles/
ansible-playbook -i localhost, -c local install.yml

cowsayを実行する

cowsay hello

 _______
< hello >
 -------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

詳しい使い方はこちらを参考にして下さい

Cureutils

インストール

ansible-joke-programs/cureutils | GitHub からPlaybookを取得し ansible-playbook コマンドをroot権限で実行します。

git clone https://github.com/ansible-joke-programs/cureutils.git
cd cureutils
ansible-galaxy install -r roles/requirements.yml -p /roles/
ansible-playbook -i localhost, -c local install.yml

Cureutilsを実行する

cure version

コマンドオプション

コマンド 効果
cure date [OPTIONS] [+FORMAT] Display date, time and Precure related events.
cure echo [OPTIONS] PATTERN Print messages of Precure.
cure girls [OPTIONS] Print girls' name.
cure grep [OPTIONS] PATTERN Print lines matching a pattern.
cure help [COMMAND] Describe available commands or one specific
cure humanize Change precure_name to human_name.
cure janken Let's play "Pikarin Janken" !
cure precures [OPTIONS] Print Precure names.
cure tr PATTERN REPLACE Translate Precure related parameters.
cure transform Change human_name to precure_name.
cure version Output the version number.

詳しい使い方については こちら を参考にして下さい

Fortune

インストール方法

ansible-joke-programs/fortune | GitHub からPlaybookを取得し ansible-playbook コマンドをroot権限で実行します。

git clone https://github.com/ansible-joke-programs/fortune.git
cd fortune
ansible-galaxy install -r roles/requirements.yml -p /roles/
ansible-playbook -i localhost, -c local install.yml

詳しい使い方は fortune(6) - Linux man pageを参考にして下さい

Nyancat

インストール方法

ansible-joke-programs/nyancat | GitHub からPlaybookを取得し ansible-playbook コマンドをroot権限で実行します。

git clone https://github.com/ansible-joke-programs/nyancat.git
cd nyancat
ansible-galaxy install -r roles/requirements.yml -p /roles/
ansible-playbook -i localhost, -c local install.yml

Nyancatを実行する

nyancat

# control + c  で終了

コマンドオプション

オプション 効果
-i --intro Show the introduction / about information at startup.
-t --telnet Telnet mode.
-n --no-counter Do not display the timer
-s --no-title Do not set the titlebar text
-e --no-clear Do not clear the display between frames
-f --frames Display the requested number of frames, then quit
-r --min-rows Crop the animation from the top
-R --max-rows Crop the animation from the bottom
-c --min-cols Crop the animation from the left
-C --max-cols Crop the animation from the right
-W --width Crop the animation to the given width
-H --height Crop the animation to the given height
-h --help Show this help message.

pong-command

インストール方法

ansible-joke-programs/pong-command | GitHub からPlaybookを取得し ansible-playbook コマンドをroot権限で実行します。

git clone https://github.com/ansible-joke-programs/pong-command.git
cd pong-command
ansible-galaxy install -r roles/requirements.yml -p /roles/
ansible-playbook -i localhost, -c local install.yml

pongを実行する

pong <何らかの文字>

# ゲームが開始される
# ESCキーで終了

sl

インストール方法

ansible-joke-programs/sl | GitHub からPlaybookを取得し ansible-playbook コマンドをroot権限で実行します。

git clone https://github.com/ansible-joke-programs/sl.git
cd sl
ansible-galaxy install -r roles/requirements.yml -p /roles/
ansible-playbook -i localhost, -c local install.yml

コマンドオプション

オプション 効果
-l 細長いSLが走る
-a 車内の客が「HELP!」と叫んでいる
-F 空(画面の上のほう)へ飛んでゆく

参考リンク

元ネタ

ASCIIQuarium

beer-mug

CMatrix

cowsay

Cureutils

Fortune

Nyancat

pong-command

sl

使用したAnsible Playbook

ASCIIQuarium

beer-mug

  • 工事中

CMatrix

cowsay

Cureutils

Fortune

Nyancat

pong-command

sl

7
2
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
7
2