cowsayとansibleインストール便利ワンライナー
- OS再インストールした後Ansibleを実行させたいが、ansibleが入っていない場合インストールさせる
run.sh
if [ ! -e /usr/bin/ansible ];then sudo apt-get install -y ansible cowsay; fi
cowsayを入れておくとAnsibleの出力結果が見やすい
出力例
< TASK: packages | install mail >
-------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
ok: [localhost] => (item=sharutils,postfix,mailutils,mutt) => {"changed": false, "item": "sharutils,postfix,mailutils,mutt"}
_________________________________
< TASK: packages | install guiapp >
---------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
changed: [localhost] => (item=firefox-locale-ja,pinta) => {"changed": true, "item": "firefox-locale-ja,pinta", "stderr": "", "stdout": "Reading package lists...\nBuilding dependency tree...\nReading state information...\nThe following NEW packages will be installed:\n pinta\n0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.\nNeed to get 557 kB of archives.\nAfter this operation, 2766 kB of additional disk space will be used.\nGet:1 http://ftp.tsukuba.wide.ad.jp/Linux/ubuntu/ trusty-updates/universe pinta all 1.3-3ubuntu0.14.04.2 [557 kB]\nFetched 557 kB in 0s (1842 kB/s)\nSelecting previously unselected package pinta.\n(Reading database ... 166704 files and directories currently installed.)\nPreparing to unpack .../pinta_1.3-3ubuntu0.14.04.2_all.deb ...\nUnpacking pinta (1.3-3ubuntu0.14.04.2) ...\nProcessing triggers for man-db (2.6.7.1-1ubuntu1) ...\nProcessing triggers for gnome-menus (3.10.1-0ubuntu2) ...\nProcessing triggers for desktop-file-utils (0.22-1ubuntu1) ...\nProcessing triggers for bamfdaemon (0.5.1+14.04.20140409-0ubuntu1) ...\nRebuilding /usr/share/applications/bamf-2.index...\nProcessing triggers for mime-support (3.54ubuntu1.1) ...\nProcessing triggers for hicolor-icon-theme (0.13-1) ...\nSetting up pinta (1.3-3ubuntu0.14.04.2) ...\n"}
___________________________________
< TASK: packages | install rdesktop >
-----------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
changed: [localhost] => (item=rdesktop,tightvncserver,xtightvncviewer) => {"changed": true, "item": "rdesktop,tightvncserver,xtightvncviewer", "stderr": "", "stdout": "Reading package lists...\nBuilding dependency tree...\nReading state information...\nSuggested packages:\n tightvnc-java\nThe following NEW packages will be installed:\n tightvncserver xtightvncviewer\n0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.\nNeed to get 682 kB of archives.\nAfter this operation, 1980 kB of additional disk space will be used.\nGet:1 http://ftp.tsukuba.wide.ad.jp/Linux/ubuntu/ trusty/universe tightvncserver amd64 1.3.9-6.4ubuntu1 [629 kB]\nGet:2 http://ftp.tsukuba.wide.ad.jp/Linux/ubuntu/ trusty/universe xtightvncviewer amd64 1.3.9-6.4ubuntu1 [53.0 kB]\nFetched 682 kB in 0s (1015 kB/s)\nSelecting previously unselected package tightvncserver.\n(Reading database ... 166779 files and directories currently installed.)\nPreparing to unpack .../tightvncserver_1.3.9-6.4ubuntu1_amd64.deb ...\nUnpacking tightvncserver (1.3.9-6.4ubuntu1) ...\nSelecting previously unselected package xtightvncviewer.\nPreparing to unpack .../xtightvncviewer_1.3.9-6.4ubuntu1_amd64.deb ...\nUnpacking xtightvncviewer (1.3.9-6.4ubuntu1) ...\nProcessing triggers for doc-base (0.10.5) ...\nProcessing 1 added doc-base file...\nRegistering documents with scrollkeeper...\nProcessing triggers for man-db (2.6.7.1-1ubuntu1) ...\nSetting up tightvncserver (1.3.9-6.4ubuntu1) ...\nupdate-alternatives: using /usr/bin/tightvncserver to provide /usr/bin/vncserver (vncserver) in auto mode\nupdate-alternatives: using /usr/bin/Xtightvnc to provide /usr/bin/Xvnc (Xvnc) in auto mode\nupdate-alternatives: using /usr/bin/tightvncpasswd to provide /usr/bin/vncpasswd (vncpasswd) in auto mode\nSetting up xtightvncviewer (1.3.9-6.4ubuntu1) ...\nupdate-alternatives: using /usr/bin/xtightvncviewer to provide /usr/bin/vncviewer (vncviewer) in auto mode\n"}
_____________________________________________________
/ TASK: dotfiles | copy src= dest=/home/user1/. owner=user1 \
\ group=user1 mode=0644 /
-----------------------------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
ok: [localhost] => (item=vimrc) => {"changed": false, "dest": "/home/user1/.vimrc", "gid": 1000, "group": "user1", "item": "vimrc", "md5sum": "edaf1669bc649941da4a1266158b2a49", "mode": "0644", "owner": "user1", "path": "/home/user1/.vimrc", "size": 61, "state": "file", "uid": 1000}
ok: [localhost] => (item=gitconfig) => {"changed": false, "dest": "/home/user1/.gitconfig", "gid": 1000, "group": "user1", "item": "gitconfig", "md5sum": "75a80f11daca0625e9cfd369a838d90f", "mode": "0644", "owner": "user1", "path": "/home/user1/.gitconfig", "size": 50, "state": "file", "uid": 1000}
ok: [localhost] => (item=bash_custom) => {"changed": false, "dest": "/home/user1/.bash_custom", "gid": 1000, "group": "user1", "item": "bash_custom", "md5sum": "8c3df5c3571b2b1afe30ba177bfbcde9", "mode": "0644", "owner": "user1", "path": "/home/user1/.bash_custom", "size": 100, "state": "file", "uid": 1000}
dotfilesの便利ワザ
dotfiles/tasks/main.yml
---
- copy: src={{ item }} dest=/home/user1/.{{ item }} owner=user1 group=user1 mode=0644
with_items:
- vimrc
- gitconfig
- bash_custom
こうしておけばlsで出てくるので扱いやすい。
$ ls dotfiles/files/
bash_custom gitconfig vimrc