Created
August 13, 2016 09:47
-
-
Save ikuwow/368d9ba859ab75cbae4b74373f831fbd to your computer and use it in GitHub Desktop.
構成管理したサーバーにSSHした不届き者に警告メッセージを出してみる ref: http://qiita.com/ikuwow/items/81500455485239a3edcf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ssh somehost | |
Last login: Sat Aug 13 16:56:53 2016 from 0.0.0.0 | |
__| __|_ ) | |
_| ( / Amazon Linux AMI | |
___|\___|___| | |
https://aws.amazon.com/amazon-linux-ami/2016.03-release-notes/ | |
####################################################### | |
## WARNING: THIS SERVER IS CONFIGURED WITH ANSIBLE!! ## | |
####################################################### | |
!このサーバーはItamaeで構成管理されています。 ! | |
!緊急時を除き、Itamaeを使わない手動での設定変更等は! | |
!絶対に行わないでください ! | |
####################################################### | |
$ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ls /etc/update-motd.d/ | |
30-banner 70-available-updates 75-system-update |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tasks: | |
- name: Add login message | |
copy: src=motd.txt dest=/etc/update-motd.d/99-ansible-warning mode=0744 | |
notify: Reflect motd changes | |
handlers: | |
- name: Reflect motd changes | |
shell: "update-motd" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
remote_file "/etc/update-motd.d/99-itamae-warning" do | |
source "files/motd.txt" | |
mode "0744" | |
notifies :run, "execute[update-motd]" | |
end | |
execute "update-motd" do | |
command "update-motd" | |
action :nothing | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cat << EOF | |
####################################################### | |
## WARNING: THIS SERVER IS CONFIGURED WITH ANSIBLE!! ## | |
####################################################### | |
!このサーバーはItamaeで構成管理されています。 ! | |
!緊急時を除き、Itamaeを使わない手動での設定変更等は! | |
!絶対に行わないでください ! | |
####################################################### | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment