顯示文章

這裡允許您檢視這個會員的所有文章。請注意, 您只能看見您有權限閱讀的文章。


文章 - sakana

頁: [1] 2 3 ... 52
3
那只能說...........恭喜了 :p

4
ESXi 5 的版本 ?
5.5 然後是否有升級patch ?


5
那一個產品呢?
有的下載是需要登入權限的

6
報名網址

https://studyarea.kktix.cc/events/2f263587-77f30d-2013ed-ae4341-fc4884-d02efc-e152b0

時間: 2017/7/22 14:00 ~ 17:00

議題簡介

1.經驗分享

2.廣電級專業系統介紹

3.影音技術基礎

4.直播系統規劃

5.提昇直播品質

6.Q&A

 

講師:Deanger

資歷:廣電級數位影音系統方案顧問

地點: Gandi / 台北市內湖區洲子街196號


7
活動報名頁面 https://opensuse-tw.kktix.cc/events/ansible-opensuse-101

[簡介]
 

Ansible 自動化組態工具 workshop with openSUSE 101

本活動由 openSUSE Taiwan x Study Area  共同主辦

* Study Area 酷學園 FB: https://www.facebook.com/sataiwan/

* openSUSE Taiwan FB: https://www.facebook.com/groups/opensuse.zh/

場地由摩茲工寮 https://moztw.org/space/ 提供

 

請自備筆電參加 workshop,  建議安裝 openSUSE 版本的桌面系統
 

[課程說明]

簡介:
Ansible 為目前 Configuration Management 四大金釵( Puppet / Salt / Chef / Ansible )之一.

希望利用3個小時的時間跟大家聊聊或是讓大家動手玩 Ansible ( 自己動手, 豐衣足食 ) ( 暫定, 主辦單位有更動內容的權力,  好像都是這樣寫 :stuck_out_tongue: ) .

主要是希望有接觸資訊系統的人可以一起聊聊及討論了解相關想法.  ( 其實也不需要俱備先備知識 )

 

可能會聊聊下面的東西 ^^

    Ansible ? Why Ansible?

    預備知識

    安裝 Ansible

    The role of Ansible

    與 shell script 的差異??

    Hello Ansible!! 第一個 ansible 指令

    Inventory file / ansible.cfg 介紹

    Ansible Module 介紹與實作

    Playbook 介紹與實做

    Reference


講師: sakana

講師簡介:
Study-Area 酷學園 小雜工  / GNOME.Asia Committee Member / openSUSE Member

    喜歡社群自由無私的分享、熱愛自由軟體及 Linux 所帶來的方便性

 

[注意事項]
由於內容將為工作坊,請參加者攜帶筆記型電腦並充滿電力 (安裝 openSUSE Leap 42.2 or openSUSE Tumbleweed 者大感謝。)(使用虛擬機或是遠端桌面亦可)

取得 openSUSE 版本: https://www.opensuse.org/

 

[適合對象]

開放原始碼愛好者
想要了解  Ansible 安裝以及入門的社群朋友
 

[課程時程]

14:00 - 17:00  Workshop 工作坊

8
Linux 討論版 / nagios with openSUSE Leap 42.2 小記
« 於: 2017-01-02 16:06 »
原文網址 : http://sakananote2.blogspot.tw/2016/12/nagios-with-opensuse-leap-422.html

目的: 監控 目前專案還有自己的設備
監控公共服務或是主機是否活著

OS: openSUSE Leap 42.2

安裝 nagios 相關套件, plugins 套件的名稱也改了, 現在叫 monitoring-plugins

代碼: [選擇]
# zypper  install   nagios  monitoring-plugins
設定 nagiosadmin 密碼

傳統的方式
代碼: [選擇]
# htpasswd2   -c   /etc/nagios/htpasswd.users   nagiosadmin
New password:
Re-type new password:
Adding password for user nagiosadmin

因為考慮之後自動化要結合 ansible 所以也嘗試了 -b 與 -i 選項, 這邊比較有趣的是 -b 或是 -i 都要相選項與 -c 放在一起, 也就是 -b -c 是不行的, 要 -bc 才行

-b  batch mode 密碼要放在使用者帳號後面
代碼: [選擇]
# htpasswd2  -bc   /etc/nagios/htpasswd.users    nagiosadmin    test
Adding password for user nagiosadmin

-i  read stdin, 透過 STDIN 來餵進去密碼
代碼: [選擇]
# echo  test  |  htpasswd2  -ic   /etc/nagios/htpasswd.users    nagiosadmin
Adding password for user nagiosadmin

確認 nagios 開機啟動

代碼: [選擇]
# systemctl   is-enabled   nagios
nagios.service is not a native service, redirecting to systemd-sysv-install
Executing /usr/lib/systemd/systemd-sysv-install is-enabled nagios
disabled

設定開機啟動 nagios
代碼: [選擇]
# systemctl   enable  nagios
nagios.service is not a native service, redirecting to systemd-sysv-install
Executing /usr/lib/systemd/systemd-sysv-install enable nagios


代碼: [選擇]
# systemctl   is-enabled   nagios
nagios.service is not a native service, redirecting to systemd-sysv-install
Executing /usr/lib/systemd/systemd-sysv-install is-enabled nagios
enabled

嘗試啟動 apache2, 這個時候會出現錯誤
代碼: [選擇]
# systemctl  restart  apache2.service
Job for apache2.service failed because the control process exited with error code. See "systemctl status apache2.service" and "journalctl -xe" for details.

使用 status 觀察, 原因是 apache2.4 與 apache2.2 寫法不一樣
代碼: [選擇]
# systemctl  status  apache2.service
12月 31 11:11:50 template start_apache2[7143]: AH00526: Syntax error on line 15 of /etc/apache2/conf.d/nagios.conf:
12月 31 11:11:50 template start_apache2[7143]: Invalid command 'Order', perhaps misspelled or defined by a module not included in the server configuration
12月 31 11:11:51 template systemd[1]: apache2.service: Main process exited, code=exited, status=1/FAILURE
可以參考
    2.2 用 Order, 但是2.4 用 Require
http://stackoverflow.com/questions/10925528/invalid-command-order-perhaps-misspelled-or-defined-by-a-module-not-included
https://lists.opensuse.org/opensuse-bugs/2015-07/msg02923.html[/list]

解法啟用 access_compat 模組 ( openSUSE / SUSE 預設 authz_host 已經啟動 )
代碼: [選擇]
# a2enmod   mod_access_compat
列出已經啟用的 apache2 module
代碼: [選擇]
# apache2ctl   -M會將設定寫入 /etc/apache2/sysconfig.d/loadmodule.conf 檔案內 LoadModule access_compat_module /usr/lib64/apache2-prefork/mod_access_compat.so

重新啟動 apache2
代碼: [選擇]
# systemctl  restart  apache2.service
觀察資訊
代碼: [選擇]
# systemctl   status  apache2.service

啟動  nagios
代碼: [選擇]
# systemctl  start  nagios
觀察資訊
代碼: [選擇]
# systemctl  status nagios
開啟 http 服務
代碼: [選擇]
#yast2   firewall
預設如果啟動 nagios, 他會去檢查本機 http 服務, 但是沒有預設網頁就會警告, 還有如果監控的項目比較多, total process 也會超標, 所以我調整了一下 /etc/nagios/objects/localhost.cfg  相關內容

代碼: [選擇]
#vi   /etc/nagios/objects/localhost.cfg
註解 HTTP, linux-servers 群組 以及調整 Total Process
# 2014/1/8 edit by sakana, temp disable HTTP monitor
#define service{
#        use         local-service         ; Name of service template to use
#        host_name                       localhost
#        service_description             HTTP
#       check_command                   check_http
#       notifications_enabled           0
#        }

# Define an optional hostgroup for Linux machines
#
#define hostgroup{
#        hostgroup_name  linux-servers ; The name of the hostgroup
#        alias           Linux Servers ; Long name of the group
#        members         localhost     ; Comma separated list of hosts that belong to this group
#        }


# 2014/1/8 edit by sakana change check_local_procs from 250 to 400, 400 to 800
define service{
        use                             local-service         ; Name of service template to use
        host_name                       localhost
        service_description             Total Processes
        check_command                   check_local_procs!400!800!RSZDT
        }

上面其實只是說明, 如果需求跟我一樣懶得動手改, 可以抓網路上我已經改好的
( 其實也是為了自己自動化 )

代碼: [選擇]
# wget  https://raw.githubusercontent.com/sakanamax/LearnAnsible/master/playbook/general/nagios/files/localhost.cfg
--2016-12-31 12:21:29--  https://raw.githubusercontent.com/sakanamax/LearnAnsible/master/playbook/general/nagios/files/localhost.cfg
正在查找主機 raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.100.133
正在連接 raw.githubusercontent.com (raw.githubusercontent.com)|151.101.100.133|:443... 連上了。
已送出 HTTP 要求,正在等候回應... 200 OK
長度: 5546 (5.4K) [text/plain]
Saving to: ‘localhost.cfg’

100%[=====================================================================================================================>] 5,546       --.-K/s   in 0s     

2016-12-31 12:21:30 (28.9 MB/s) - ‘localhost.cfg’ saved [5546/5546]

目前目錄下就會有 localhost.cfg
代碼: [選擇]
# ls
bin  Desktop  Documents  Downloads  inst-sys  localhost.cfg  Music  Pictures  Public  Templates  Videos

將localhost.cfg 取代 /etc/nagios/objects/localhost.cfg ( 謎之音: 記得先備份?? )
代碼: [選擇]
# mv    localhost.cfg   /etc/nagios/objects/localhost.cfg

修改通知 e-mail 
代碼: [選擇]
# vi   /etc/nagios/objects/contacts.cfg
修改預設的  e-mail
define contact{
        contact_name    nagiosadmin    ; Short name of user
        use    generic-contact         ; Inherit default values from generic-contact template (defined above)
        alias       Nagios Admin            ; Full name of user
        email  自己帳號@郵件 ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
        }


檢視 Nagios 設定有沒有問題
代碼: [選擇]
#nagios  -v   /etc/nagios/nagios.cfg
重新啟動 Nagios
代碼: [選擇]
# systemctl  restart  nagios.service
結果如下






安裝 nagios-nrpe 套件

代碼: [選擇]
# zypper  install  nrpe  monitoring-plugins-nrpe
下載之前自己建立的範本檔案
代碼: [選擇]
# wget  https://raw.githubusercontent.com/sakanamax/LearnAnsible/master/playbook/general/nagios/files/templates.cfg

--2016-12-31 16:13:07--  https://raw.githubusercontent.com/sakanamax/LearnAnsible/master/playbook/general/nagios/files/templates.cfg
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.100.133
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.100.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 19833 (19K) [text/plain]
Saving to: ‘templates.cfg’

100%[=====================================================================================================================>] 19,833      --.-K/s   in 0.06s   

2016-12-31 16:13:07 (324 KB/s) - ‘templates.cfg’ saved [19833/19833]

確認目前目錄下有 templates.cfg
代碼: [選擇]
# ls
Desktop  Documents  Downloads  Music  Pictures  Public  Templates  Videos  bin  inst-sys  templates.cfg


覆蓋且移動原來的設定檔
代碼: [選擇]
# mv    templates.cfg   /etc/nagios/objects/templates.cfg
下載之前自己建立的範本commands.cfg檔案
代碼: [選擇]
# wget  https://raw.githubusercontent.com/sakanamax/LearnAnsible/master/playbook/general/nagios/files/commands.cfg

--2016-12-31 16:18:12--  https://raw.githubusercontent.com/sakanamax/LearnAnsible/master/playbook/general/nagios/files/commands.cfg
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.100.133
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.100.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 7876 (7.7K) [text/plain]
Saving to: ‘commands.cfg’

100%[=====================================================================================================================>] 7,876       --.-K/s   in 0s     

2016-12-31 16:18:13 (60.2 MB/s) - ‘commands.cfg’ saved [7876/7876]


確認 commands.cfg 已經下載
代碼: [選擇]
# ls
Desktop  Documents  Downloads  Music  Pictures  Public  Templates  Videos  bin  commands.cfg  inst-sys

覆蓋且移動原來的設定檔
代碼: [選擇]
# mv    commands.cfg    /etc/nagios/objects/commands.cfg
建立之後存放 Server 與 一般工作站的設定檔目錄
代碼: [選擇]
#mkdir   /etc/nagios/servers
#mkdir   /etc/nagios/pcs
#mkdir   /etc/nagios/racks
#mkdir  /etc/nagios/switches
#mkdir   /etc/nagios/projects
#mkdir   /etc/nagios/labs

取得事先寫好的 linuxPublic.cfg, windowsPublic.cfg 複製給公用服務使用並複製到 /etc/nagios/objects目錄

代碼: [選擇]
# wget  https://raw.githubusercontent.com/sakanamax/LearnAnsible/master/playbook/general/nagios/files/linuxPublic.cfg

--2016-12-31 16:37:12--  https://raw.githubusercontent.com/sakanamax/LearnAnsible/master/playbook/general/nagios/files/linuxPublic.cfg
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.100.133
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.100.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2652 (2.6K) [text/plain]
Saving to: ‘linuxPublic.cfg’

100%[=====================================================================================================================>] 2,652       --.-K/s   in 0s     

2016-12-31 16:37:12 (28.7 MB/s) - ‘linuxPublic.cfg’ saved [2652/2652]

代碼: [選擇]
# mv   linuxPublic.cfg   /etc/nagios/objects/
代碼: [選擇]
# wget  https://raw.githubusercontent.com/sakanamax/LearnAnsible/master/playbook/general/nagios/files/windowsPublic.cfg

--2016-12-31 16:38:37--  https://raw.githubusercontent.com/sakanamax/LearnAnsible/master/playbook/general/nagios/files/windowsPublic.cfg
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.100.133
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.100.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2345 (2.3K) [text/plain]
Saving to: ‘windowsPublic.cfg’

100%[=====================================================================================================================>] 2,345       --.-K/s   in 0s     

2016-12-31 16:38:37 (23.4 MB/s) - ‘windowsPublic.cfg’ saved [2345/2345]

代碼: [選擇]
# mv   windowsPublic.cfg   /etc/nagios/objects/
取得事先寫好的 switchSimple.cfg, rackHost.cfg 複製給switch, 機器服務使用並複製到 /etc/nagios/objects目錄

代碼: [選擇]
# wget   https://raw.githubusercontent.com/sakanamax/LearnAnsible/master/playbook/general/nagios/files/switchSimple.cfg

--2016-12-31 16:41:58--  https://raw.githubusercontent.com/sakanamax/LearnAnsible/master/playbook/general/nagios/files/switchSimple.cfg
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.100.133
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.100.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3365 (3.3K) [text/plain]
Saving to: ‘switchSimple.cfg’

100%[=====================================================================================================================>] 3,365       --.-K/s   in 0s     

2016-12-31 16:41:58 (29.6 MB/s) - ‘switchSimple.cfg’ saved [3365/3365]
代碼: [選擇]
# mv   switchSimple.cfg   /etc/nagios/objects/
代碼: [選擇]
# wget   https://raw.githubusercontent.com/sakanamax/LearnAnsible/master/playbook/general/nagios/files/rackHost.cfg

--2016-12-31 16:43:38--  https://raw.githubusercontent.com/sakanamax/LearnAnsible/master/playbook/general/nagios/files/rackHost.cfg
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.100.133
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.100.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2716 (2.7K) [text/plain]
Saving to: ‘rackHost.cfg’

100%[=====================================================================================================================>] 2,716       --.-K/s   in 0s     

2016-12-31 16:43:38 (18.2 MB/s) - ‘rackHost.cfg’ saved [2716/2716]

代碼: [選擇]
# mv   rackHost.cfg   /etc/nagios/objects/

取得事先寫好的 windows.cfg 複製給windows 服務使用並複製到 /etc/nagios/objects目錄

代碼: [選擇]
# wget   https://raw.githubusercontent.com/sakanamax/LearnAnsible/master/playbook/general/nagios/files/windows.cfg

--2016-12-31 16:53:25--  https://raw.githubusercontent.com/sakanamax/LearnAnsible/master/playbook/general/nagios/files/windows.cfg
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.100.133
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.100.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4023 (3.9K) [text/plain]
Saving to: ‘windows.cfg’

100%[=====================================================================================================================>] 4,023       --.-K/s   in 0s     

2016-12-31 16:53:25 (45.9 MB/s) - ‘windows.cfg’ saved [4023/4023]

代碼: [選擇]
# mv   windows.cfg    /etc/nagios/objects/

取得事先寫好的 nagios.cfg 主要是修改使用 cfg_dir= 並複製到 /etc/nagios目錄

代碼: [選擇]
# wget  https://raw.githubusercontent.com/sakanamax/LearnAnsible/master/playbook/general/nagios/files/nagios.cfg

--2016-12-31 16:48:01--  https://raw.githubusercontent.com/sakanamax/LearnAnsible/master/playbook/general/nagios/files/nagios.cfg
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.100.133
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.100.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 44650 (44K) [text/plain]
Saving to: ‘nagios.cfg’

100%[=====================================================================================================================>] 44,650      --.-K/s   in 0.1s   

2016-12-31 16:48:01 (397 KB/s) - ‘nagios.cfg’ saved [44650/44650]

代碼: [選擇]
# mv    nagios.cfg   /etc/nagios/
檢視 Nagios 設定有沒有問題
代碼: [選擇]
#nagios  -v   /etc/nagios/nagios.cfg這邊可能會有警告, 因為 rack 主機我們只檢查主機不檢查服務

重新啟動 Nagios
代碼: [選擇]
# systemctl  restart  nagios.service
結果如下



Part II:   Nagios 用戶端-- Linux 伺服器用戶端建置

請於 Client 端

1.安裝 nagios-nrpe套件

代碼: [選擇]
# zypper  install  nrpe  monitoring-plugins-nrpe monitoring-plugins
2.設定nagios-nrpe 套件
(另外最好去確認 /etc/services 有沒有 nrpe 5666/tcp # nagios nrpe 的設定)
代碼: [選擇]
#grep  5666  /etc/services
修改設定檔 允許 Nagios 伺服器連線 ( 設定檔位置有改變, 目前為 /etc/nrpe.cfg )
代碼: [選擇]
# vi  /etc/nrpe.cfg

allowed_hosts=127.0.0.1,192.168.100.199

(請依照實際的IP 作為修正, 可能為 10.x.x.x )
這邊要注意 127.0.0.1後面要加上 逗點 , 然後主機 IP 不能有空格
不然會出現沒有辦法建立 SSL HandShake
(這個部份可以解釋, 如果nrpe是使用 SystemV 的形式啟動後面都會出現不能建立SSL Handshake ,但是以Xinetd 就不會)


啟動 NRPE
代碼: [選擇]
# systemctl   start   nrpe
檢查狀態 ( 這邊有看到 /run/nrpe/nrpe.pid 無法建立, 但是目前測試沒有影響查詢, 如果不放心就建立 /run/nrpe 然後給 nagios 寫入權限 )
代碼: [選擇]
# systemctl  status nrpe

● nrpe.service - Daemon to remotely execute Nagios plugins
   Loaded: loaded (/usr/lib/systemd/system/nrpe.service; enabled; vendor preset: disabled)
   Active: active (running) since 六 2016-12-31 19:17:50 CST; 3min 50s ago
  Process: 3457 ExecStart=/usr/sbin/nrpe -c /etc/nrpe.cfg -d (code=exited, status=0/SUCCESS)
 Main PID: 3461 (nrpe)
    Tasks: 1 (limit: 512)
   CGroup: /system.slice/nrpe.service
           └─3461 /usr/sbin/nrpe -c /etc/nrpe.cfg -d

12月 31 19:17:50 template systemd[1]: Starting Daemon to remotely execute Nagios plugins...
12月 31 19:17:50 template systemd[1]: Started Daemon to remotely execute Nagios plugins.
12月 31 19:17:50 template nrpe[3461]: Starting up daemon
12月 31 19:17:50 template nrpe[3461]: Cannot write to pidfile '/run/nrpe/nrpe.pid' - check your privileges.

設定開機啟動 NRPE
代碼: [選擇]
# systemctl   enable  nrpe
確認開機啟動
代碼: [選擇]
# systemctl  is-enabled    nrpe
enabled
請於Client 端
執行 check_nrpe 測試, 成功應該會出現 NRPE的版本
代碼: [選擇]
# /usr/lib/nagios/plugins/check_nrpe   -H   127.0.0.1
NRPE v2.15

*************************************************************
請於 Server 端

針對 nagios client 測試 nagios-nrpe 成功應該會出現 NRPE的版本
代碼: [選擇]
#/usr/lib/nagios/plugins/check_nrpe  -H  192.168.100.100
NRPE v2.15

(這邊請確認 firewall 是否關閉, 或是准許 nrpe 通過, 可以使用 #yast2  firewall 關閉防火牆測試  或是下指令 #rcSuSEfirewall2  stop )


*************************************************************[/color]


請於Client 端
加入相關 nrpe 指令 ( 因為目前已經沒有 hda1 了 )
代碼: [選擇]
#vi   /etc/nagios/nrpe.cfg
加入
#command[check_hda1]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /dev/hda1
command[check_sda1]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /dev/sda1
command[check_sda2]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /dev/sda2
command[check_ssh]=/usr/lib/nagios/plugins/check_ssh   127.0.0.1
command[check_smtp]=/usr/lib/nagios/plugins/check_smtp  127.0.0.1

也可以用之前已經做好的 nrpe.cfg

代碼: [選擇]
# wget  https://raw.githubusercontent.com/sakanamax/LearnAnsible/master/playbook/general/nagios/files/nrpe.cfg

--2016-12-31 19:49:29--  https://raw.githubusercontent.com/sakanamax/LearnAnsible/master/playbook/general/nagios/files/nrpe.cfg
正在查找主機 raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.100.133
正在連接 raw.githubusercontent.com (raw.githubusercontent.com)|151.101.100.133|:443... 連上了。
已送出 HTTP 要求,正在等候回應... 200 OK
長度: 8474 (8.3K) [text/plain]
Saving to: ‘nrpe.cfg’

100%[===========================================================================>] 8,474       --.-K/s   in 0s     

2016-12-31 19:49:29 (53.1 MB/s) - ‘nrpe.cfg’ saved [8474/8474]

代碼: [選擇]
#vi   /etc/nagios/nrpe.cfg
(如果IP有改就改 allowed_hosts= 後面接的IP吧 !! )
覆蓋原來的檔案
代碼: [選擇]
# mv   nrpe.cfg   /etc/
重新啟動
代碼: [選擇]
# systemctl   restart  nrpe
測試相關指令
代碼: [選擇]
# /usr/lib/nagios/plugins/check_nrpe   -H 127.0.0.1   -c   check_sda2
DISK OK - free space: / 12753 MB (69% inode=97%);| /=5661MB;14732;16573;0;18415

代碼: [選擇]
# /usr/lib/nagios/plugins/check_nrpe  -H 127.0.0.1  -c  check_users
USERS OK - 2 users currently logged in |users=2;5;10;0

代碼: [選擇]
# /usr/lib/nagios/plugins/check_nrpe   -H 127.0.0.1   -c   check_load
OK - load average: 0.00, 0.00, 0.00|load1=0.000;15.000;30.000;0; load5=0.000;10.000;25.000;0; load15=0.000;5.000;20.000;0;

代碼: [選擇]
# /usr/lib/nagios/plugins/check_nrpe   -H 127.0.0.1   -c   check_total_procs
PROCS OK: 208 processes | procs=208;250;300;0;

另外於 Server端測試 相關的指令
代碼: [選擇]
# /usr/lib/nagios/plugins/check_nrpe  -H 192.168.100.100   -c check_sda2
DISK OK - free space: / 12753 MB (69% inode=97%);| /=5661MB;14732;16573;0;18415




Part III:   將linux 伺服器(Nagios Client)加入到 Nagios監控範圍

請於Server上面

下載事先做好的 linux.cfg 範本
代碼: [選擇]
# wget   https://raw.githubusercontent.com/sakanamax/LearnAnsible/master/playbook/general/nagios/files/linux.cfg

--2016-12-31 20:14:49--  https://raw.githubusercontent.com/sakanamax/LearnAnsible/master/playbook/general/nagios/files/linux.cfg
正在查找主機 raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.100.133
正在連接 raw.githubusercontent.com (raw.githubusercontent.com)|151.101.100.133|:443... 連上了。
已送出 HTTP 要求,正在等候回應... 200 OK
長度: 3664 (3.6K) [text/plain]
Saving to: ‘linux.cfg’

100%[===================================================================>] 3,664       --.-K/s   in 0s     

2016-12-31 20:14:49 (19.2 MB/s) - ‘linux.cfg’ saved [3664/3664]
移動到 /etc/nagios/objects 下
代碼: [選擇]
# mv    linux.cfg   /etc/nagios/objects/
**設定 Nagios 載入 linux client 的設定檔 **

依照不同的性質將範本設定檔 linux.cfg 複製到不同目錄我們建立了
/etc/nagios/labs - 監控實驗機器
/etc/nagios/servers - 監控服務機器
/etc/nagios/pcs - 監控pc
/etc/nagios/projects - 監控專案機器
/etc/nagios/racks - 監控機架 IPMI
/etc/nagios/switches - 監控 switch

假設有台 linux 服務機器要監控
將剛剛的 linux.cfg 複製給 linux server 使用並複製到 /etc/nagios/servers目錄
代碼: [選擇]
# cp  /etc/nagios/objects/linux.cfg   /etc/nagios/servers/linux100.cfg
確認IP設定無誤
代碼: [選擇]
#vi   /etc/nagios/servers/linux100.cfg
address         192.168.3.129 請改成實際的IP
host_name     suseserver129 請改成實際的名稱
確認設定檔是否無誤
代碼: [選擇]
# nagios   -v   /etc/nagios/nagios.cfg
重新啟動 nagios 使其生效
代碼: [選擇]
# systemctl   restart    nagios
結果如下




大功告成

~ enjoy it

9
先 tar 起來再解開?

10
活動報名頁面 http://opensuse-tw.kktix.cc/events/docker101

[簡介]
 

Docker and openSUSE workshop 101

本活動由 openSUSE Taiwan x Study Area x NCTU 330 共同主辦

* Study Area 酷學園 FB: https://www.facebook.com/sataiwan/

* openSUSE Taiwan FB: https://www.facebook.com/groups/opensuse.zh/

* NCTU 330 KKTIX: http://nctu330.kktix.cc/

 

請自備筆電參加 workshop, 如果有 vi 或是文字編輯器更佳 :)

 

在這個  workshop 內我們會介紹

* docker 介紹

* 安裝 docker

* docker 映像檔管理

-- 下載映像檔並觀察

-- 映像檔查詢與取得

* 建立 docker 映像檔 -- 修改現有映像檔方式

* 建立 docker 映像檔 -- 使用 Dockerfile

* 硬像檔管理 - Tag 與刪除映像檔

* 交流時間


[適合對象]

開放原始碼愛好者
想要了解  Docker 安裝以及入門
 

[課程時程]

19:00 - 21:00

 

[講者]

Sakana

Study-Area 酷學園 小雜工  / GNOME.Asia Committee Member / openSUSE Member

喜歡社群自由無私的分享、熱愛自由軟體及 Linux 所帶來的方便性.

 

[系列活動資訊]
2016 年9月24日(詳情請見臉書社團公佈) - openSUSE Taiwan & Study Area
主題:Open Build Service 實作練習 Workshop 101
地點:摩茲工寮
共同主辦社群: Study-Area

預定 2016 10月(詳情請見臉書社團公佈) - openSUSE Taiwan & Study Area
主題:Docker and openSUSE workshop 101
地點:摩茲工寮(預定)
共同主辦社群: Study-Area

11
沒有試過這個 module

看你的錯誤訊息是 ssh 連線問題

看這個模組的介紹是實作部份 rsync
http://docs.ansible.com/ansible/synchronize_module.html

所以你要去 rsync 的 a and b 是否需要 ssh 連線
光就他的介紹我覺得是 control machine and manage node 的同步
我之前是使用比較麻煩的方式
先用 fetch module 複製到 control machine 然後在透過 copy module 複製過去

如果這個 module 可以達成, 也不錯
期待您的成功回報 :)

12
DevOps 討論版 / Spark 本機安裝 with Ansible
« 於: 2016-06-27 17:06 »
圖文並茂版本在 http://sakananote2.blogspot.tw/2016/06/spark-with-ansible.html

Spark 本機安裝 with Ansible
現在的實驗環境會透過 Ansible 來管理

 所以整理了一下 spark local 套件安裝的 ansible playbook
使用 group 方式控管
安裝 spark 相關套件, 透過變數詢問下載不同版本, 預設是 1.4.0
使用 when: 方式針對不同的 OS 來安裝, 目前有 openSUSE Leap, CentOS, 還有 ubuntu
目前已測試 openSUSE 42.1 / CentOS 7.2 / Ubuntu 14.04

 檔案 spark_local.yml

代碼: [選擇]
- name: Install spark with local
  hosts: sparkSingle
#  透過 vars_prompt 動態詢問要裝的版本, 預設是 1.4.0
  vars_prompt:
    - name: "spark_version"
      prompt: "Please enter spark version, example 1.4.0"
      private: no
      default: "1.4.0"

   tasks:
    - name: Install java, wget  with openSUSE Leap
# Use sudo before ansible 1.9
#      sudo: True
      become: True
# 使用 pkg 加上 {{ item }} 配合後面的 with_item 來安裝多個套件
      zypper: name={{ item }}
      with_items:
        - java-1.7.0-openjdk-devel
        - wget
      when: ansible_distribution == "openSUSE Leap"

     - name: Install java, wget with CentOS
      become: True
      yum: name={{ item }}
      with_items:
        - java-1.7.0-openjdk-devel
        - wget
      when: ansible_distribution == "CentOS"

     - name: Install java, wget and scala with Ubuntu
      become: True
      apt: name={{ item }} update_cache=yes
      with_items:
        - openjdk-7-jdk
        - wget
        - scala
      when: ansible_distribution == "Ubuntu"

 # ----------------------------------------------------------

     - name: Get scala
      shell: wget http://www.scala-lang.org/files/archive/scala-2.10.1.tgz
      when: ansible_distribution == "CentOS" or ansible_distribution == "openSUSE Leap"

     - name: Exact source code of scala
      shell: tar xvf scala-2.10.1.tgz
      when: ansible_distribution == "CentOS" or ansible_distribution == "openSUSE Leap"

     - name: Move scala to /usr/lib
      become: True
      shell: mv scala-2.10.1 /usr/lib
      when: ansible_distribution == "CentOS" or ansible_distribution == "openSUSE Leap"

     - name: create link for scala
      become: True
      shell: ln -s /usr/lib/scala-2.10.1/  /usr/lib/scala
      when: ansible_distribution == "CentOS" or ansible_distribution == "openSUSE Leap"

     - name: touch .bashrc
      shell: touch ~/.bashrc
      when: ansible_distribution == "CentOS" or ansible_distribution == "openSUSE Leap"

     - name: export $PATH to .bashrc
      lineinfile: dest=~/.bashrc line="export PATH=$PATH:/usr/lib/scala/bin"
      when: ansible_distribution == "CentOS" or ansible_distribution == "openSUSE Leap"

 # ----------------------------------------------------------


# 由於沒有在 general option 使用 sudo, 這邊在使用 shell module 抓下來就是使用者自己的身份額非 root
# 這邊用 spark 1.4.0 版本
    - name: Download spark with pre-build hadoop
        shell: wget    http://archive.apache.org/dist/spark/spark-{{ spark_version }}/spark-{{ spark_version }}-bin-hadoop2.6.tgz

 # 解開 source code
    - name: Exact pre-build source
      shell: tar zxvf spark-*.tgz

     - name: Rename spark folder
      shell: mv ~/spark*/ ~/spark


# 測試 jps 指令
    - name: Testing jps command
      command: jps
      register: jps
    - debug: var=jps.stdout_lines

 執行方式

 將要安裝 spark 的主機加入 sparkSingle 群組
然後執行 spark_local.yml 即可

 先記下來

 ~ enjoy it

13
圖文並茂版本
https://sakananote2.blogspot.tw/2016/06/ansible-vsphereguest-with-opensuse-2.html
https://sakananote2.blogspot.tw/2016/06/ansible-vsphereguest-module-with.html

OS: openSUSE Leap 42.1

Ansible: 2.1.0.0
Module: vsphere_guest

    http://docs.ansible.com/ansible/vsphere_guest_module.html


Requirements (on host that executes module)

    python >= 2.6
    pysphere


檢查需求
# python --version
Python 2.7.9

pysphere 的部份

    https://software.opensuse.org/package/python-pysphere?search_term=pysphere


參考之前的網誌
加入套件庫
代碼: [選擇]
# zypper  --gpg-auto-import-keys   addrepo   -f  http://download.opensuse.org/repositories/devel:/languages:/python/openSUSE_Leap_42.1/devel:languages:python.repo
搜尋套件
代碼: [選擇]
# zypper   search   -s   sphere
Loading repository data...
Reading installed packages...

S | Name            | Type       | Version   | Arch   | Repository                         
--+-----------------+------------+-----------+--------+------------------------------------
  | python-pysphere | package    | 0.1.8-1.1 | noarch | Python Modules (openSUSE_Leap_42.1)

安裝 pysphere
代碼: [選擇]
# zypper  install   python-pysphere
Loading repository data...
Reading installed packages...
Resolving package dependencies...

The following NEW package is going to be installed:
  python-pysphere

1 new package to install.
Overall download size: 891.9 KiB. Already cached: 0 B. After the operation, additional 13.8 MiB will be used.
Continue? [y/n/? shows all options] (y):  Y
建立測試 playbook
後來採用 local 的方式執行, 然後相關資訊使用 var_prompt 的方式

檔案 Test_vsphere_guest_get_facts.yml

代碼: [選擇]
- name: Testing vsphere_guest module in VMware
# 這邊自己習慣控管 VMware 的是用本機
# 配合 hosts 內的 ansible_connection=local
  hosts: localhost
# 設定使用 local connection
  connection: local
# 這種方式還不錯, 透過提示來輸入相關變數
  vars_prompt:
# 這邊的 name 就會是變數的名稱
    - name: "vcenter_hostname"
# 設定提示文字
      prompt: "Enter vcenter hostname"
# private 設定為 no 會顯示輸入的內容
      private: no
# 這邊可以設定預設值
      default: "vcsa"

    - name: "vcenter_user"
      prompt: "Enter vCenter username"
      private: no
      default: root

    - name: "vcenter_pass"
      prompt: "Enter vcenter password"
# private 設定為 yes 會顯示輸入的內容
      private: yes

    - name: "guest_name"
      prompt: "Enter guest vm name"
      private: no


  tasks:
    - name: Testing gater facts from vSphere
# 使用 vsphere_guest 來設定相關工作
      vsphere_guest:
# vCenter 的 IP 或是 FQDN, 這邊用上面的變數讓使用者輸入
        vcenter_hostname: "{{ vcenter_hostname }}"
# Ansible 2.1 以後的版本可以設定 validate_certs, 預設會檢查 SSL certs, 如果是自己架設的vC, 可以設定no
        validate_certs: no
# vCenter 上面的使用者名稱, 對應上面的變數
        username: "{{ vcenter_user }}"
# vCenter 使用者的密碼, 對應上面的變數
        password: "{{ vcenter_pass }}"
# 要針對的 VMware guest 名稱
        guest: "{{ guest_name }}"
# 是否要取回 guest 資訊
        vmware_guest_facts: yes

下指令執行還有輸出結果

代碼: [選擇]
> ansible-playbook   -v   test_vsphere_guest_get_facts.yml
Enter vcenter hostname [vcsa]:  YOURIP_FQDN
Enter vCenter username [root]:
Enter vcenter password:
Enter guest vm name: openSUSELeap_SA_Docker

PLAY [Testing vsphere_guest module in VMware] **********************************

TASK [setup] *******************************************************************
ok: [localhost]

TASK [Testing gater facts from vSphere] ****************************************
ok: [localhost] => {"ansible_facts": {"hw_eth0": {"addresstype": "manual", "ipaddresses": [“w.x.y.z", "fe80::220:5fff:fe11:1111"], "label": "Network adapter 1", "macaddress": "00:50:56:11:11:11", "macaddress_dash": "00-50-56-11-11-11", "summary": "VM Net"}, "hw_guest_full_name": "Other Linux (32-bit)", "hw_guest_id": "otherLinuxGuest", "hw_interfaces": ["eth0"], "hw_memtotal_mb": 3976, "hw_name": "openSUSELeap_SA_Docker", "hw_power_status": "POWERED ON", "hw_processor_count": 2, "hw_product_uuid": "4222b4d6-ef7b-dc72-8603-9f7cbbfc2737", "module_hw": true}, "changed": false}

PLAY RECAP *********************************************************************
localhost                  : ok=2    changed=0    unreachable=0    failed=0   


建立 test_vsphere_guest_delete_vm.yml

代碼: [選擇]
- name: Testing vsphere_guest module in VMware
# 這邊自己習慣控管 VMware 的是用本機
# 配合 hosts 內的 ansible_connection=local
  hosts: localhost
# 設定使用 local connection
  connection: local
# 這種方式還不錯, 透過提示來輸入相關變數
  vars_prompt:
# 這邊的 name 就會是變數的名稱
    - name: "vcenter_hostname"
# 設定提示文字
      prompt: "Enter vcenter hostname"
# private 設定為 no 會顯示輸入的內容
      private: no
# 這邊可以設定預設值
      default: "vcsa"
    - name: "vcenter_user"
      prompt: "Enter vCenter username"
      private: no
      default: root
    - name: "vcenter_pass"
      prompt: "Enter vcenter password"
# private 設定為 yes 會顯示輸入的內容
      private: yes
    - name: "guest_name"
      prompt: "Enter guest VM name your want to delete"
      private: no
  tasks:
    - name: Delete VM
# 使用 vsphere_guest 來設定相關工作
      vsphere_guest:
# vCenter 的 IP 或是 FQDN, 這邊用上面的變數讓使用者輸入
        vcenter_hostname: "{{ vcenter_hostname }}"
# Ansible 2.1 以後的版本可以設定 validate_certs, 預設會檢查 SSL certs, 如果是自己架設的vC, 可以設定no
        validate_certs: no
# vCenter 上面的使用者名稱, 對應上面的變數
        username: "{{ vcenter_user }}"
# vCenter 使用者的密碼, 對應上面的變數
        password: "{{ vcenter_pass }}"
# 要針對的 VMware guest 名稱
        guest: "{{ guest_name }}"
#
        state: absent
# 如果有使用 force: yes, 就是虛擬機不需要先關機就刪除
# 實際上觀察, 是會先關機然後刪除
        force: yes     
這樣可以用來刪除指定的 VM

 檔案 test_vsphere_guest_deploy_from_template.yml
代碼: [選擇]
- name: Testing vsphere_guest module in VMware
# 這邊自己習慣控管 VMware 的是用本機
# 配合 hosts 內的 ansible_connection=local
  hosts: localhost
  connection: local
# 這種方式還不錯, 透過提示來輸入相關變數
  vars_prompt:
# 這邊的 name 就會是變數的名稱
    - name: "vcenter_hostname"
# 設定提示文字
      prompt: "Enter vcenter hostname"
# private 設定為 no 會顯示輸入的內容
      private: no
# 這邊可以設定預設值
      default: "vcsa"

    - name: "vcenter_user"
      prompt: "Enter vCenter username"
      private: no
      default: root

    - name: "vcenter_pass"
      prompt: "Enter vcenter password"
# private 設定為 yes 會顯示輸入的內容
      private: yes

    - name: "esxi_hostname"
      prompt: "Enter esxi hostname"
      private: no

    - name: "template_name"
      prompt: "Enter Template name"
      private: no
      default: openSUSELeap42.1_Training_Template

  tasks:
    - name: Create VM from template
# 可以用 with_sequence 方式, %0x 為序號, x 為16進制, 所以我用 10進制 u
# 如果是 %02x 就是 2位數, 例如 server00
# 如果只設定 server%0x , 但是超出1位數, 例如 1 to 10, 最後一個會變成 servera
# stride=2 代表間隔是 2
      with_sequence: start=1 end=10 stride=1 format=server%02u

# 用 with_item 正面表列
#      with_items:
#        - server01
#        - server02

# 使用 vsphere_guest 來設定相關工作
      vsphere_guest:
# vCenter 的 IP 或是 FQDN, 這邊用上面的變數讓使用者輸入
        vcenter_hostname: "{{ vcenter_hostname }}"
# Ansible 2.1 以後的版本可以設定 validate_certs, 預設會檢查 SSL certs, 如果是自己架設的vC, 可以設定no
        validate_certs: no
# vCenter 上面的使用者名稱, 對應上面的變數
        username: "{{ vcenter_user }}"
# vCenter 使用者的密碼, 對應上面的變數
        password: "{{ vcenter_pass }}"
# 要針對的 VMware guest 名稱
        guest: "{{ item }}"
# 從範本複製
# 如果有 from_template 就不能設定 state
        from_template: yes
# 範本名稱
        template_src: "{{ template_name }}"
# 複製範本完是否要開機, 預設是 yes
        power_on_after_clone: no
# 要佈署的 esxi 主機
        esxi:
          datacenter: Lab
          hostname: "{{ esxi_hostname }}"
     
# 目前測試 resource_pool 沒有成功
#        resource_pool: "/Resources"
在 VMware 上面的結果



然後應用相同的方式也讓刪除 VM 可以刪除多個
測試 reconfig 功能

    目前只支援 cdroom, mem 還有 cpu 數量的更改


檔案 test_vsphere_guest_reconfig_vm.yml

代碼: [選擇]
- name: Testing vsphere_guest module in VMware
# 這邊自己習慣控管 VMware 的是用本機
# 配合 hosts 內的 ansible_connection=local
  hosts: localhost
  connection: local
# 這種方式還不錯, 透過提示來輸入相關變數
  vars_prompt:
# 這邊的 name 就會是變數的名稱
    - name: "vcenter_hostname"
# 設定提示文字
      prompt: "Enter vcenter hostname"
# private 設定為 no 會顯示輸入的內容
      private: no
# 這邊可以設定預設值
      default: "vcsa"

    - name: "vcenter_user"
      prompt: "Enter vCenter username"
      private: no
      default: root

    - name: "vcenter_pass"
      prompt: "Enter vcenter password"
# private 設定為 yes 會顯示輸入的內容
      private: yes

    - name: "esxi_hostname"
      prompt: "Enter esxi hostname"
      private: no

  tasks:
    - name: Reconfig VM
#  'reconfigured' only applies changes to 'vm_cdrom', 'memory_mb', and 'num_cpus' in vm_hardware parameter.
#
# 可以用 with_sequence 方式, %0x 為序號, 10進制是用 u, 所以用 %02u
# 如果是 %02x 就是 2位數, 例如 server00
# 如果只設定 server%0x , 但是超出1位數, 例如 1 to 10, 最後一個會變成 servera
      with_sequence: start=1 end=5 stride=1 format=server%02u

# 用 with_item 正面表列
#      with_items:
#        - server01
#        - server02

# 使用 vsphere_guest 來設定相關工作
      vsphere_guest:
# vCenter 的 IP 或是 FQDN, 這邊用上面的變數讓使用者輸入
        vcenter_hostname: "{{ vcenter_hostname }}"
# Ansible 2.1 以後的版本可以設定 validate_certs, 預設會檢查 SSL certs, 如果是自己架設的vC, 可以設定no
        validate_certs: no
# vCenter 上面的使用者名稱, 對應上面的變數
        username: "{{ vcenter_user }}"
# vCenter 使用者的密碼, 對應上面的變數
        password: "{{ vcenter_pass }}"
# 要針對的 VMware guest 名稱
        guest: "{{ item }}"

# 如果有 from_template 就不能設定 state
        state: reconfigured

        vm_hardware:
          memory_mb: 2048
#          num_cpus: 4

# 如果設定 force: yes, 就會先關機然後設定再開機
# 有些設定必須在 VM 關機的狀況才能實施
        force: yes
# 要佈署的 esxi 主機
        esxi:
          datacenter: Lab
          hostname: "{{ esxi_hostname }}"
另外就是建立 VM 設定檔

    只有建立新 VM 設定檔, 沒有包含安裝
    folder的話要是範本與機器有的folder


檔案 test_vsphere_guest_create_newvm.yml

代碼: [選擇]
- name: Testing vsphere_guest module in VMware
# 這邊自己習慣控管 VMware 的是用本機
# 配合 hosts 內的 ansible_connection=local
  hosts: localhost
  connection: local
# 這種方式還不錯, 透過提示來輸入相關變數
  vars_prompt:
# 這邊的 name 就會是變數的名稱
    - name: "vcenter_hostname"
# 設定提示文字
      prompt: "Enter vcenter hostname"
# private 設定為 no 會顯示輸入的內容
      private: no
# 這邊可以設定預設值
      default: "vcsa"

    - name: "vcenter_user"
      prompt: "Enter vCenter username"
      private: no
      default: root

    - name: "vcenter_pass"
      prompt: "Enter vcenter password"
# private 設定為 yes 會顯示輸入的內容
      private: yes

    - name: "esxi_hostname"
      prompt: "Enter esxi hostname"
      private: no


  tasks:
    - name: Create New VM
# 可以用 with_sequence 方式, %0x 為序號
# 如果是 %02x 就是 2位數, 例如 server00
# 如果只設定 server%0x , 但是超出1位數, 例如 1 to 10, 最後一個會變成 servera
# stride=2 代表間隔是 2
      with_sequence: start=0 end=1 stride=1 format=server%02x

# 用 with_item 正面表列
#      with_items:
#        - server01
#        - server02

# 使用 vsphere_guest 來設定相關工作
      vsphere_guest:
# vCenter 的 IP 或是 FQDN, 這邊用上面的變數讓使用者輸入
        vcenter_hostname: "{{ vcenter_hostname }}"
# Ansible 2.1 以後的版本可以設定 validate_certs, 預設會檢查 SSL certs, 如果是自己架設的vC, 可以設定no
        validate_certs: no
# vCenter 上面的使用者名稱, 對應上面的變數
        username: "{{ vcenter_user }}"
# vCenter 使用者的密碼, 對應上面的變數
        password: "{{ vcenter_pass }}"
# 要針對的 VMware guest 名稱
        guest: "{{ item }}"
#
# 如果有 from_template 就不能設定 state
        state: powered_off
#
        vm_extra_config:
          vcpu.hotadd: yes
          mem.hotadd:  yes
          notes: Create by Ansible
# 這邊的 Folder 必須是在虛擬機器與範本下的 folder, 不是主機與叢集下的 folder
          folder: Ansible
          resource_pool: "Resources"
        vm_disk:
          disk1:
            size_gb: 10
            type: thin
            datastore: Local_30.3
#
        vm_nic:
          nic1:
            type: vmxnet3
            network: Lab-192-168-100
            network_type: standard
#
        vm_hardware:
          memory_mb: 2048
          num_cpus: 2
# osid 可以參考 https://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.vm.GuestOsDescriptor.GuestOsIdentifier.html
          osid: sles11_64Guest
          scsi: paravirtual
          vm_cdrom:
            type: "iso"
            iso_path: "Local_30.3/ISO/SLE-12-SP1-Server-DVD-x86_64-GM-DVD1.iso"

# VMware 硬體版本
        vm_hw_version: vmx-08
# 要佈署的 esxi 主機
        esxi:
          datacenter: Lab
          hostname: "{{ esxi_hostname }}"



先記下來

~ enjoy it

14
個人觀點
* 這本手冊可能會比暗殺教室的修學旅行手冊還厚很多
---- 如果真的有這本手冊, 幾千頁, 使用者不一定會翻或是搜尋, 可能還是打電話給 MIS ?

感覺你的主管就是想做
所以我的想法可能就是 --- 做然後讓使用者覺得不可行然後翻案或是改正

畢竟你是下對上 ( You -- > 主管 )
改為上對下 ( 同仁 -- > 你主管 )
勝算可能大一點

:)

15
原文在此 http://sakananote2.blogspot.tw/2016/05/ansible-consul-in-opensuse-leap-421.html

以 ansible 安裝 consul in openSUSE Leap 42.1
Consul with ansible

因為之後 docker swarm 需要用到 consul , 所以就建立 consul

 OS: openSUSE Leap 42.1

一般建立 consul 的作法

 建立使用者 consul  ( 不一定要建立這個使用者, 這個是工作上協調的結果 )
代碼: [選擇]
#useradd  -m  consul
建立相關目錄
代碼: [選擇]
#mkdir  -p  /opt/consul/bin   /opt/consul/data   /opt/consul/config
設定權限以及更改擁有人為使用者 consul
代碼: [選擇]
#chown  -R  consul   /opt/consul/

 #chmod  -R  700  /opt/consul/

 從網路取得 consul 並解壓縮 zip ( 這邊以 0.6.4 為例 )

 
代碼: [選擇]
#wget   https://releases.hashicorp.com/consul/0.6.4/consul_0.6.4_linux_amd64.zip

 #unzip  consul_0.6.4_linux_amd64.zip
將 consul 複製到指定的目錄
代碼: [選擇]
#cp  consul   /opt/consul/bin
切換使用者 consul
代碼: [選擇]
#su  -  consul
編寫設定檔 ( 這邊我們是先試用官方的服務 https://atlas.hashicorp.com/consul  )
>vi   /opt/consul/config/atlas_consul.json


代碼: [選擇]
{
  "bind_addr": "請填入機器IP",
  "atlas_infrastructure": "請填入帳號/請填入名稱",
  "atlas_join": true,
  "atlas_token": "請填入自己的token",
  "bootstrap_expect": 3,
  "datacenter": "Hsinchu-NCHC",
  "data_dir": "/opt/consul/data",
  "log_level": "INFO",
  "node_name": "請填入主機名稱",
  "encrypt": "請填入加密的資訊",
  "server": true
}


啟動 consul agent
代碼: [選擇]
> /opt/consul/bin/consul   agent   -config-dir   /opt/consul/config/
目前是用 nohup 方式在背景執行, 然後離開
代碼: [選擇]
> nohup /opt/consul/bin/consul agent -config-dir /opt/consul/config/ &
停止 consul 的方式( 這樣不會產生 error )
代碼: [選擇]
/opt/consul/bin/consul  leave




 ------- Ansible 方式 ----------



 接下來自己寫了一個 ansible 的playbook 來安裝 consul

 檔案名稱 Consul_install.yml

代碼: [選擇]
---
######################################################### 
# Install consul and setup boot
- name: use when conditionals and setup module (facts)
  hosts: all
  tasks:
# 使用 setup moudule 列出 OS 種類
    - name: use setup module to list os distribution
# setup moudle 可以使用 filter 過濾相關內容
      setup: filter=ansible_distribution


######################################################### 

 - name: Install consul , add user and setting up env
# use group
  hosts: ConsulHost
  sudo: True
  tasks:
    - name: Add user consul
      user: name=consul

     - name: Create folder for consul
      file: path=/opt/consul/{{ item }} state=directory owner=consul mode=700
      with_items:
        - bin
        - data
        - config

     - name: Install wget with openSUSE Leap
      zypper: name={{ item }}
      with_items:
        - wget
      when: ansible_distribution == "openSUSE Leap"

     - name: Install wget with CentOS
      yum: name={{ item }}
      with_items:
        - wget
      when: ansible_distribution == "CentOS"

     - name: Install wget with Ubuntu
      apt: name={{ item }} update_cache=yes
      with_items:
        - wget
      when: ansible_distribution == "Ubuntu"

 #------------------------------------------------------- 

     - name: Get consul 0.6.4 zip
      shell: wget   https://releases.hashicorp.com/consul/0.6.4/consul_0.6.4_linux_amd64.zip

 #------------------------------------------------------- 

     - name: Unzip consul 0.6.4 zip file
      shell: unzip consul_0.6.4_linux_amd64.zip

 #------------------------------------------------------- 

     - name: Copy consul to path
      shell: cp consul /opt/consul/bin

 ######################################################### 
# Copy config files with user consul
- name: copy config files with user consul
  hosts: ConsulHost
  tasks:
    - name: use setup module to list os distribution
      become_user: consul
      become: yes
      template: src=templates/atlas_consul.json dest=/opt/consul/config/atlas_consul.json

 # 這個部份有待討論如何在背景執行 可能要寫成服務的方式, 目前會斷
#    - name: running consul at backgroud
#      become_user: consul
#      become: yes
#      shell: nohup /opt/consul/bin/consul agent -config-dir /opt/consul/config &

檔案 templates/atlas_consul.json

代碼: [選擇]
{% for host in groups['ConsulHost'] %}
{
  "bind_addr": "{{ hostvars[host].ansible_default_ipv4.address }}",
  "atlas_infrastructure": "請填入帳號/請填入名稱",
  "atlas_join": true,
  "atlas_token": "請填入自己的token",
  "bootstrap_expect": 3,
  "datacenter": "Hsinchu-NCHC",
  "data_dir": "/opt/consul/data",
  "log_level": "INFO",
  "node_name": "{{ hostvars[host].ansible_hostname }}",
  "encrypt": "請填入加密的資訊",
  "server": true
}
{% endfor %}

16
報名網址 https://edu.nchc.org.tw/course/one_course_introduction.asp?lms_auto_course_id=2930&from_course_list_url=course_index

課程名稱: Apache Spark 建置與開發實務課程 (台中)
上課地點: 國家高速網路與計算中心(台中) 交通方式 http://www.nchc.org.tw/tw/traffic.php
上課時間: 2016/6/16 (四) ~ 2016/6/17 (五) 09:30 ~ 16:30
上課總天數:2 天,共計 12 個小時

提供午餐:   是
招生人數:   6 ~ 10  人
 
講師:   
國家高速網路與計算中心 - 軟體發展組    莊家雋  博士
國家高速網路與計算中心 - 軟體發展組    陳威宇  副研究員

 
報名費用:   
一般人士   3600 元
學生   2800 元

課程介紹:   
Hadoop是近年來為了大資料分析而發展出來的數據處理架構,其中的二個關鍵技術HDFS與MapReduce,建構出大資料分析的執行環境和服務。但隨著大資料分析的多元化,Hadoop並不能滿足新的需求,因此,針對Hadoop系統中的各種問題,柏克萊大學提出了全新統一的大數據處理架構Spark,創新的提出RDD概念,可視為MapReduce模型的擴充,可以實現在MapReduce不容易實現的計算工作,例如反覆運算、互動式和串流工作等 。
本課程將帶領學員了解大資料領域中Spark core 中最主要的RDD概念。以實作方式讓學員從無到有建置 Spark環境,並建立其叢集系統,獲得大資料處理的基礎能力,並進而了解各式Spark子系統的功用,並開發各式大資料分析的創新應用。

課程內容安排:   
01. Why Spark
02. Programming with RDD
03. Run on Cluster
04. Play with Spark Ecosystem

17
很感謝 交大資工提供社群共用空間
http://nctu330.kktix.cc/

讓社群可以有地方交流 :)

sakana 就貢獻一場 淺談 Ansible 自動化組態管理工具

報名網址
http://nctu330.kktix.cc/events/ansible-intro

活動議題:

      淺談 Ansible 自動化組態管理工具



議程簡介 :

     這次來淺談 ( 注意是淺談喔 ~ ) Ansible的相關議題.

Ansible 為目前 Configuration Management 四大金釵( Puppet / Salt / Chef / Ansible )之一.

希望利用2個小時的時間跟大家聊聊或是讓大家動手玩 Ansible ( 自己動手, 豐衣足食 ) ( 暫定, 主辦單位有更動內容的權力,  好像都是這樣寫 :p ) .

主要是希望有接觸資訊系統的人可以一起聊聊及討論了解相關想法.  ( 其實也不需要俱備先備知識 )



可能會聊聊下面的東西 ^^

     Ansible ? Why Ansible?

     預備知識

     安裝 Ansible

     The role of Ansible

     與 shell script 的差異??

     Hello Ansible!! 第一個 ansible 指令

     Inventory file / ansible.cfg 介紹

     Ansible Module 介紹與實作

     Playbook 介紹與實做

     Reference



     應用想法討論?

     也希望可以讓來參加的人一起聊聊 Ansible.

     希望大家輕鬆討論, 悠閒度過討論時光 ( 包含我自己 XD )

StudyArea酷學園
FB https://www.facebook.com/sataiwan/
討論區 http://phorum.study-area.org/
KKTIX 活動頁面 http://studyarea.kktix.cc/




講師: sakana  ( Max? )



講師簡介:

     Study-Area 酷學園 小雜工  / GNOME.Asia Committee Member / openSUSE Member

     喜歡社群自由無私的分享、熱愛自由軟體及 Linux 所帶來的方便性.



時間:

     2016年5月16日 (星期一)

     下午19:00~21:00

     時間規劃: 2 hr



地點:

     新竹交通大學工程三館330教室



費用: 免費(最貴)


活動報名網址:
   
http://nctu330.kktix.cc/events/ansible-intro

主辦單位:

     Study area酷!學園
     NCTU 330

19
原文連結 http://sakananote2.blogspot.tw/2016/03/docker-unstable-package-install-with.html

最近因為工作實驗環境需要, 需要安裝 docker 比較新的版本
寫了安裝小記還有 ansible playbook 檔案

OS: openSUSE Leap 42.1
套件安裝: docker 1.10.x 以上版本
(考慮實驗環境可能會測試 UCP 或是其他功能)

目前 docker 在 openSUSE Leap 42.1 官方版本為 1.9.x

套件版本查詢
之前進行套件查詢的時候都是使用 #zypper  search 套件名稱
為了有更多的資訊, 以後會多一些參數

代碼: [選擇]
# zypper   search   -s   --match-exact   docker
Loading repository data...
Reading installed packages...

S | Name   | Type       | Version    | Arch   | Repository               
--+--------+------------+------------+--------+--------------------------
  | docker | package    | 1.9.1-13.1 | x86_64 | openSUSE-Leap-42.1-Update
  | docker | package    | 1.9.1-10.1 | x86_64 | openSUSE-Leap-42.1-Update
  | docker | package    | 1.9.1-7.1  | x86_64 | openSUSE-Leap-42.1-Update
  | docker | package    | 1.9.0-4.1  | x86_64 | openSUSE-Leap-42.1-Update
  | docker | package    | 1.8.2-2.5  | x86_64 | openSUSE-Leap-42.1-Oss   

大概就是加上 -s 以及 --match-exact 這兩個 option
-s 顯示更多資訊, 但是沒有 -v 那麼多
--match-exact 符合後面字串的套件
感覺效果像 --match-words ^docker$

因為要安裝非穩定版本以及想要批次安裝

初步嘗試想法
*使用 OneClickInstallCLI 搭配 .ymp 方式來安裝
相關檔案如下
http://software.opensuse.org/ymp/Virtualization:containers/openSUSE_Leap_42.1/docker.ymp

但是目前 OneClickInstallCLI 不可以使用非互動方式安裝, 所以暫時作罷

目前作法
在 software.opensuse.org 搜尋 docker
http://software.opensuse.org/package/docker
點選 Virtualization:container

到專案頁面
點選 Repositories
看到 The repositories are inherited from the project Virtualization:containers.
點選 Virtualization:containers 專案 -- > 點選 Repositories

這邊可以找到各個版本的 repositories 下載


我用的是 Leap 42.1 所以 點選 openSUSE_Leap 42.1 的連結
http://download.opensuse.org/repositories/Virtualization:/containers/openSUSE_Leap_42.1

這邊可以看到 .repo 檔案


連結為
http://download.opensuse.org/repositories/Virtualization:/containers/openSUSE_Leap_42.1/Virtualization:containers.repo

透過 zypper 指令來新增 repo, 加入 key 以及設定 refresh

代碼: [選擇]
# zypper  --gpg-auto-import-keys   addrepo   -f http://download.opensuse.org/repositories/Virtualization:/containers/openSUSE_Leap_42.1/Virtualization:containers.repo--gpg-auto-import-keys  是自動匯入 repo的 key
-f 為設定 auto refresh

透過 zypper repos 來查詢

代碼: [選擇]
# zypper   repos
#  | Alias                     | Name                                           | Enabled | GPG Check | Refresh
---+---------------------------+------------------------------------------------+---------+-----------+--------
 1 | Virtualization_containers | Virtualization:containers (openSUSE_Leap_42.1) | Yes     | ( p) Yes  | Yes   
 2 | openSUSE-42.1-0           | openSUSE-42.1-0                                | No      | ----      | No     

代碼: [選擇]
# zypper  -n  install  docker
Loading repository data...
Reading installed packages...
Resolving package dependencies...

The following 7 NEW packages are going to be installed:
  bridge-utils docker docker-image-migrator git-core git-gui gitk perl-Error

The following recommended package was automatically selected:
  docker-image-migrator

7 new packages to install.
Overall download size: 12.9 MiB. Already cached: 0 B. After the operation, additional 59.4 MiB will be used.
Continue? [y/n/? shows all options] (y): y
Retrieving package docker-image-migrator-1.0.2-7.1.x86_64           
-n  新版的zypper 使用 -n / --non-interactive 來避免互動

接下來準備啟動服務

確認目前狀態
代碼: [選擇]
# systemctl   status  docker
docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled)
   Active: inactive (dead)
     Docs: http://docs.docker.com

啟動 docker
代碼: [選擇]
# systemctl  start   docker
確認目前狀態
代碼: [選擇]
# systemctl  status docker
docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled)
   Active: active (running) since Thu 2016-03-31 11:00:58 CST; 2s ago
     Docs: http://docs.docker.com
 Main PID: 32272 (docker)
   CGroup: /system.slice/docker.service
           └─32272 /usr/bin/docker daemon -H fd://

設定開機啟動

確認目前狀態
代碼: [選擇]
# systemctl  is-enabled  docker
disabled

設定開機啟動
代碼: [選擇]
# systemctl  enable  docker
確認目前狀態
代碼: [選擇]
# systemctl  is-enabled   docker
enabled

-------------------------------------------------

另外寫了 ansible 的 playbook .yml 來進行安裝
原始檔可以在這邊取得 https://github.com/sakanamax/LearnAnsible/blob/master/playbook/general/docker_unstable_openSUSELeap42.1_install.yml

檔案如下
# cat   docker_unstable_openSUSELeap42.1_install.yml
代碼: [選擇]
---
######################################################### 
# Install docker package and setup boot with unstable repo in openSUSE Leap 42.1
- name: use when conditionals and setup module (facts)
  hosts: all
  tasks:
# 使用 setup moudule 列出 OS 種類
    - name: use setup module to list os distribution
# setup moudle 可以使用 filter 過濾相關內容
      setup: filter=ansible_distribution

######################################################### 

- name: Install docker and run service
# use [dockerUnstable] group to install
  hosts: dockerUnstable
  sudo: True
  tasks:
# Add Virtualization:container project repo
    - name: Add Virutalization:containers repo
      shell: zypper  --gpg-auto-import-keys   addrepo   -f http://download.opensuse.org/repositories/Virtualization:/containers/openSUSE_Leap_42.1/Virtualization:containers.repo

    - name: Install docker with openSUSE Leap
      zypper: name={{ item }}
      with_items:
        - docker
        - curl
      when: ansible_distribution == "openSUSE Leap"

#------------------------------------------------------- 

    - name: Set docker enable and run
      service: name=docker state=started enabled=yes

20
好康報報 / SUSE Expert Day 2016 研討會
« 於: 2016-03-07 13:23 »
SUSE Expert Day 2016

2016年4月1日(星期五)
集思台大會議中心:蘇格拉底廳

主要會放在 SUSE 與 openstack / docker / ceph

會議資訊
http://www.bestcom.com.tw/content.aspx?RID=9406&CH_ID=579

報名網頁
https://events.suse.com/events/suse-expert-days-taipei/registration-3c9c9eed7726444c899cd6c5c99c8bb8.aspx

21
謝謝今天來的朋友
附上今天的簡報
https://goo.gl/1DWUqt

也希望大家給我們今天參加的回饋
^^

22
歡迎大家帶 Notebook 來一起動手玩 :-)

23
+1
贊成提案

24
謝謝大家今天的參與
希望有聊到大家有興趣的部分

會後聚餐很開心(咦?)

附上簡報
http://goo.gl/9g5u1l

今天上課環境的 docker images
https://hub.docker.com/u/sakana/

還請大家多多回饋意見 :-)

25
sakana + Ines

26
^^
感謝提醒
因為沒有注意到時區
還請您幫忙再看看是否修正完成

27
他錯誤訊息是驗證錯誤
 plaintext: 401 Unauthorized. basic auth failed

ansible.cfg 他抓的是 global 的
 /etc/ansible/ansible.cfg

這個是你希望他抓的 ansible.cfg 嗎?



28
呵呵~淺談,聽了之後,感覺是深談....
一向都是淺談, 這其中一定有啥誤會 :p

29
byblas 您客氣了

大家一起討論, 我也是剛摸呢 ^^
目前是沒有用 AWS

不知道您 使用 -vvvv 秀出 verbose 資訊
$ ansbile  -vvvv 對象 -m ping
錯誤訊息有看到哪些錯誤嗎?

我 debug 會先使用 -vvvv

給您參考

30
原文在 http://sakananote2.blogspot.com/2015/11/ansible-shell-module-apt-module.html

Ansible 的 Module 可以在官網找到所有的 Module, 這邊是按照分類的 Index http://docs.ansible.com/ansible/modules_by_category.html

 今天先來介紹兩個 module - shell 與 apt

 首先是 shell module

shell
* http://docs.ansible.com/ansible/shell_module.html
* 執行 shell, 適合執行多次處理
* 例如
* ansible  testserver  -m shell  -a  ' dpkg  -l  | grep nginx'     

 shell module 跟 command module 的差別就是可以處理 pipe 之類的做法
可以把在系統習慣的執行方式透過 shell module 來執行

 指令的做法
$ ansible  cenic_master -m shell   -a   'dpkg -l  |  grep ftp'
代碼: [選擇]
cenic_master | success | rc=0 >>
ii  ftp                                 0.17-28                             amd64        classical file transfer client

 範例
ansible-playbook 方式

 建立一個 yml 檔案
$ vi  test_shell_module.yml

代碼: [選擇]
- name: Test shell module
  hosts: cenic_master
  tasks:
    - name: Test shell module
      shell: dpkg -l | grep ftp
      register: dpkg
    - debug: var=dpkg.stdout_lines
 

以 ansible-playbook 指令執行
$ ansible-playbook test_shell_module.yml

代碼: [選擇]
PLAY [Test shell module] ******************************************************

 GATHERING FACTS ***************************************************************
ok: [cenic_master]

 TASK: [Test shell module] *****************************************************
changed: [cenic_master]

 TASK: [debug var=dpkg.stdout_lines] *******************************************
ok: [cenic_master] => {
    "var": {
        "dpkg.stdout_lines": [
            "ii  ftp                                 0.17-28                             amd64        classical file transfer client",
            "ii  lftp                                4.4.13-1                            amd64        Sophisticated command-line FTP/HTTP client programs",
            "ii  openssh-sftp-server                 1:6.6p1-2ubuntu2                    amd64        secure shell (SSH) sftp server module, for SFTP access from remote machines"
        ]
    }
}

 PLAY RECAP ********************************************************************
cenic_master               : ok=3    changed=1    unreachable=0    failed=0   

另外一個 module 就是 apt

apt
* http://docs.ansible.com/ansible/apt_module.html
* ubuntu 使用, 套件管理
* 要注意 update_cache=yes 使用, 來更新套件庫
* # 可以搭配 cache_valid_time=3600 來節省重複 update,

 指令的方式
例如 安裝 telnetd 套件
$ ansible cenic_master  -s   -m  apt  -a ' name=telnetd update_cache=yes '

這邊要注意兩件事情
* -s 代表 sudo , 因為要更新套件庫還有安裝, 所以需要 sudo
* apt 通常要搭配 update_cache=yes, 來更新, 以免套件安裝有問題

範例
ansible-playbook 方式

 建立一個 yml 檔案, 這邊我們透過 with_item 的方式一次安裝多個套件
$ vi  test_apt_module.yml

代碼: [選擇]
- name: Using Iteration (with_item) to install multiple packages
  hosts: cenic_master
#  sudo: True 這邊學到 sudo 不一定要放在一般選項內, 也可以放在 task 內
  tasks:
    - name: install apt packages
# 於 apt moudule 使用 sudo
      sudo: True
# 使用 pkg 加上 {{ item }} 配合後面的 with_item 來安裝多個套件
      apt: pkg={{ item }} update_cache=yes cache_valid_time=3600
# 配合前面的 {{ item }} 來安裝多套件
      with_items:
        - openjdk-7-jdk
        - wget
        - scala

以 ansible-playbook 指令執行

 $ ansible-playbook  test_apt_module.yml

代碼: [選擇]
PLAY [Using Iteration (with_item) to install multiple packages] ***************

 GATHERING FACTS ***************************************************************
ok: [cenic_master]

 TASK: [install apt packages] **************************************************
changed: [cenic_master] => (item=openjdk-7-jdk,wget,scala)

 PLAY RECAP ********************************************************************
cenic_master               : ok=2    changed=1    unreachable=0    failed=0

okay, 今天先到這邊
~ enjoy it

頁: [1] 2 3 ... 52