add auto fetch ssl certs
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
"articleSection" : "post",
|
||||
"name" : "[筆記] inxi 蒐集詳盡的硬體資訊 \/ inxi Collect Detail Hardware Info",
|
||||
"headline" : "[筆記] inxi 蒐集詳盡的硬體資訊 \/ inxi Collect Detail Hardware Info",
|
||||
"description" : "\x3cp\x3e最近因為一直碰到硬碟故障的問題,算起來那一批同時購買的5X顆 seagate 2T硬碟,已經有一半以上故障返修了\x26hellip;.\x3c\/p\x3e\n\n\x3cp\x3e然後又因為一直沒有添購新的硬碟,只能用這些快過保\/已過保的撐著\x3c\/p\x3e\n\n\x3cp\x3e所以最近不斷的在更換機器內的硬碟,而且還沒有熱插拔!\x3c\/p\x3e\n\n\x3cp\x3e也導致原本負責處理盤點資產的同事困擾,因為跟手邊的紀錄已經對不起來了\x3c\/p\x3e\n\n\x3cp\x3e然後就變成要對資產的時候,需要一台一台登入,然後去下不同的指令,取得想要的硬體資訊,超級麻煩的!\x3c\/p\x3e",
|
||||
"description" : "\x3cp\x3e最近因為一直碰到硬碟故障的問題,算起來那一批同時購買的5X顆 seagate 2T硬碟,已經有一半以上故障返修了\x26hellip;.\x3c\/p\x3e\n\x3cp\x3e然後又因為一直沒有添購新的硬碟,只能用這些快過保\/已過保的撐著\x3c\/p\x3e\n\x3cp\x3e所以最近不斷的在更換機器內的硬碟,而且還沒有熱插拔!\x3c\/p\x3e\n\x3cp\x3e也導致原本負責處理盤點資產的同事困擾,因為跟手邊的紀錄已經對不起來了\x3c\/p\x3e\n\x3cp\x3e然後就變成要對資產的時候,需要一台一台登入,然後去下不同的指令,取得想要的硬體資訊,超級麻煩的!\x3c\/p\x3e",
|
||||
"inLanguage" : "en",
|
||||
"author" : "Eric Chang",
|
||||
"creator" : "Eric Chang",
|
||||
@@ -45,9 +45,9 @@
|
||||
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
|
||||
|
||||
<link href="https://h.cowbay.org/css/style.css?v=1626744134" rel="stylesheet" id="theme-stylesheet" type='text/css' media='all'>
|
||||
<link href="https://h.cowbay.org/css/style.css?v=1629951055" rel="stylesheet" id="theme-stylesheet" type='text/css' media='all'>
|
||||
|
||||
<link href="https://h.cowbay.org/css/custom.css?v=1626744134" rel="stylesheet" type='text/css' media='all'>
|
||||
<link href="https://h.cowbay.org/css/custom.css?v=1629951055" rel="stylesheet" type='text/css' media='all'>
|
||||
<link rel="shortcut icon" href="https://h.cowbay.org/img/favicon.ico" type="image/x-icon">
|
||||
<link rel="icon" href="https://h.cowbay.org/img/favicon.ico" type="image/x-icon">
|
||||
|
||||
@@ -81,10 +81,6 @@ if (!doNotTrack) {
|
||||
|
||||
<ul id="menu-secondary-items" class="menu-secondary-items">
|
||||
|
||||
<li class="menu-item menu-item-type-taxonomy menu-item-object-category">
|
||||
<a href="/categories/"></a>
|
||||
</li>
|
||||
|
||||
<li class="menu-item menu-item-type-taxonomy menu-item-object-category">
|
||||
<a href="/categories/ansible">ansible</a>
|
||||
</li>
|
||||
@@ -309,108 +305,83 @@ if (!doNotTrack) {
|
||||
<div class="entry-content">
|
||||
<article>
|
||||
<p>最近因為一直碰到硬碟故障的問題,算起來那一批同時購買的5X顆 seagate 2T硬碟,已經有一半以上故障返修了….</p>
|
||||
|
||||
<p>然後又因為一直沒有添購新的硬碟,只能用這些快過保/已過保的撐著</p>
|
||||
|
||||
<p>所以最近不斷的在更換機器內的硬碟,而且還沒有熱插拔!</p>
|
||||
|
||||
<p>也導致原本負責處理盤點資產的同事困擾,因為跟手邊的紀錄已經對不起來了</p>
|
||||
|
||||
<p>然後就變成要對資產的時候,需要一台一台登入,然後去下不同的指令,取得想要的硬體資訊,超級麻煩的!</p>
|
||||
|
||||
<p>幾次之後,終於決定透過ansible來做這件事</p>
|
||||
|
||||
<p>一開始的想法很簡單,就用 lshw/dmidecode這些指令去做</p>
|
||||
|
||||
<p>可是因為手邊的機器有ubuntu 18.04/16.04/14.04 , Debian 9 , Proxmox (based on debian ) , CentOS , FreeNAS</p>
|
||||
|
||||
<p>而有些系統預設沒有 lshw / dmidecode (對,FreeNAS 就是說你)</p>
|
||||
|
||||
<p>所以變成要依照系統不同,去下不同的指令,雖然都是ansible在跑,但是看到playbook的內容就很煩啊!</p>
|
||||
|
||||
<p>然後就不小心讓我翻到了 inxi 這個指令,根本就是救星啊!</p>
|
||||
|
||||
<p>直接來看輸出的範例</p>
|
||||
|
||||
<p><img src="http://i.imgur.com/OSx9cnz.png" alt="sample of inxi output" /></p>
|
||||
|
||||
<p><img src="http://i.imgur.com/OSx9cnz.png" alt="sample of inxi output"></p>
|
||||
<p>有沒有,是不是很優!</p>
|
||||
|
||||
<p>而且簡單易懂,還能抓到同事想看的資料,像是廠牌、型號、序號、記憶體類型(DDR2/3/4)</p>
|
||||
|
||||
<p>所以馬上捨棄 lshw/dmidecode ,改用 inxi 來跑</p>
|
||||
|
||||
<p>ansible role 的內容也很簡單</p>
|
||||
|
||||
<p>就偵測完之後,把結果送出給設定好的收件人</p>
|
||||
|
||||
<p>只是因為系統不同,大致上要分成 ubuntu/debian/centos 以及 freebsd 兩種</p>
|
||||
|
||||
<p>所以同樣的task 要跑兩次,一個要帶sudo 一個不用帶</p>
|
||||
|
||||
<p>然後BSD系列的機器,在inventory 裡面要帶入 ansible_ssh_user</p>
|
||||
|
||||
<p>就這樣,沒有什麼太困難的</p>
|
||||
|
||||
<pre><code class="language-YAML">######### use inxi instead ##################
|
||||
- name: copy inxi binary to remote Ubnutu/Debian
|
||||
become: yes
|
||||
become_method: sudo
|
||||
copy:
|
||||
src: inxi
|
||||
dest: /usr/local/bin/inxi
|
||||
mode: a+rx,u+rwx
|
||||
when: ansible_distribution == "Ubuntu" or ansible_distribution == "Debian" or ansible_distribution == "CentOS"
|
||||
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-YAML" data-lang="YAML"><span style="color:#75715e">######### use inxi instead ##################</span>
|
||||
- <span style="color:#66d9ef">name</span>: copy inxi binary to remote Ubnutu/Debian
|
||||
<span style="color:#66d9ef">become</span>: yes
|
||||
<span style="color:#66d9ef">become_method</span>: sudo
|
||||
<span style="color:#66d9ef">copy</span>:
|
||||
<span style="color:#66d9ef">src</span>: inxi
|
||||
<span style="color:#66d9ef">dest</span>: /usr/local/bin/inxi
|
||||
<span style="color:#66d9ef">mode</span>: a+rx,u+rwx
|
||||
<span style="color:#66d9ef">when</span>: ansible_distribution == <span style="color:#e6db74">"Ubuntu"</span> or ansible_distribution == <span style="color:#e6db74">"Debian"</span> or ansible_distribution == <span style="color:#e6db74">"CentOS"</span>
|
||||
|
||||
- name: copy inxi binary to remote FreeBSD
|
||||
copy:
|
||||
src: inxi
|
||||
dest: /usr/local/bin/inxi
|
||||
mode: a+rx,u+rwx
|
||||
when: ansible_distribution == "FreeBSD"
|
||||
- <span style="color:#66d9ef">name</span>: copy inxi binary to remote FreeBSD
|
||||
<span style="color:#66d9ef">copy</span>:
|
||||
<span style="color:#66d9ef">src</span>: inxi
|
||||
<span style="color:#66d9ef">dest</span>: /usr/local/bin/inxi
|
||||
<span style="color:#66d9ef">mode</span>: a+rx,u+rwx
|
||||
<span style="color:#66d9ef">when</span>: ansible_distribution == <span style="color:#e6db74">"FreeBSD"</span>
|
||||
|
||||
- name: run inxi to collect Ubuntu/Debian hardware info
|
||||
become: yes
|
||||
become_method: sudo
|
||||
shell: "/usr/local/bin/inxi -c -Dxx -C -m -Z"
|
||||
register: du_hw_info
|
||||
when: ansible_distribution == "Ubuntu" or ansible_distribution == "Debian" or ansible_distribution == "CentOS"
|
||||
- <span style="color:#66d9ef">name</span>: run inxi to collect Ubuntu/Debian hardware info
|
||||
<span style="color:#66d9ef">become</span>: yes
|
||||
<span style="color:#66d9ef">become_method</span>: sudo
|
||||
<span style="color:#66d9ef">shell</span>: <span style="color:#e6db74">"/usr/local/bin/inxi -c -Dxx -C -m -Z"</span>
|
||||
<span style="color:#66d9ef">register</span>: du_hw_info
|
||||
<span style="color:#66d9ef">when</span>: ansible_distribution == <span style="color:#e6db74">"Ubuntu"</span> or ansible_distribution == <span style="color:#e6db74">"Debian"</span> or ansible_distribution == <span style="color:#e6db74">"CentOS"</span>
|
||||
|
||||
- name: run inxi to collect FreeBSD hardware info
|
||||
shell: "/usr/local/bin/inxi -c -Dxx -C -m -Z"
|
||||
register: bsd_hw_info
|
||||
when: ansible_distribution == "FreeBSD"
|
||||
- <span style="color:#66d9ef">name</span>: run inxi to collect FreeBSD hardware info
|
||||
<span style="color:#66d9ef">shell</span>: <span style="color:#e6db74">"/usr/local/bin/inxi -c -Dxx -C -m -Z"</span>
|
||||
<span style="color:#66d9ef">register</span>: bsd_hw_info
|
||||
<span style="color:#66d9ef">when</span>: ansible_distribution == <span style="color:#e6db74">"FreeBSD"</span>
|
||||
|
||||
- name: set Ubuntu/Debian inventory file
|
||||
template:
|
||||
src: etc/inventory.txt.j2
|
||||
dest: "/tmp/{{ ansible_hostname }}_inventory.txt"
|
||||
mode: a+r,u+rw
|
||||
when: ansible_distribution == "Ubuntu" or ansible_distribution == "Debian" or ansible_distribution == "CentOS"
|
||||
- <span style="color:#66d9ef">name</span>: set Ubuntu/Debian inventory file
|
||||
<span style="color:#66d9ef">template</span>:
|
||||
<span style="color:#66d9ef">src</span>: etc/inventory.txt.j2
|
||||
<span style="color:#66d9ef">dest</span>: <span style="color:#e6db74">"/tmp/{{ ansible_hostname }}_inventory.txt"</span>
|
||||
<span style="color:#66d9ef">mode</span>: a+r,u+rw
|
||||
<span style="color:#66d9ef">when</span>: ansible_distribution == <span style="color:#e6db74">"Ubuntu"</span> or ansible_distribution == <span style="color:#e6db74">"Debian"</span> or ansible_distribution == <span style="color:#e6db74">"CentOS"</span>
|
||||
|
||||
- name: set FreeBSD inventory file
|
||||
template:
|
||||
src: etc/freenas_inventory.txt.j2
|
||||
dest: "/tmp/{{ ansible_hostname }}_inventory.txt"
|
||||
mode: a+r,u+rw
|
||||
when: ansible_distribution == "FreeBSD"
|
||||
- <span style="color:#66d9ef">name</span>: set FreeBSD inventory file
|
||||
<span style="color:#66d9ef">template</span>:
|
||||
<span style="color:#66d9ef">src</span>: etc/freenas_inventory.txt.j2
|
||||
<span style="color:#66d9ef">dest</span>: <span style="color:#e6db74">"/tmp/{{ ansible_hostname }}_inventory.txt"</span>
|
||||
<span style="color:#66d9ef">mode</span>: a+r,u+rw
|
||||
<span style="color:#66d9ef">when</span>: ansible_distribution == <span style="color:#e6db74">"FreeBSD"</span>
|
||||
|
||||
- name: send inventory file via mail
|
||||
tags: mail
|
||||
mail:
|
||||
host: 192.168.11.173
|
||||
port: 25
|
||||
secure: starttls
|
||||
subject: "{{ ansible_hostname }} inventory file"
|
||||
from: ansible
|
||||
to: "{{ recipient }}"
|
||||
#body: "{{ mail_body.stdout_lines }}"
|
||||
attach: "/tmp/{{ ansible_hostname }}_inventory.txt"
|
||||
|
||||
</code></pre>
|
||||
|
||||
<p>inventory 內容</p>
|
||||
- <span style="color:#66d9ef">name</span>: send inventory file via mail
|
||||
<span style="color:#66d9ef">tags</span>: mail
|
||||
<span style="color:#66d9ef">mail</span>:
|
||||
<span style="color:#66d9ef">host</span>: <span style="color:#ae81ff">192.168.11.173</span>
|
||||
<span style="color:#66d9ef">port</span>: <span style="color:#ae81ff">25</span>
|
||||
<span style="color:#66d9ef">secure</span>: starttls
|
||||
<span style="color:#66d9ef">subject</span>: <span style="color:#e6db74">"{{ ansible_hostname }} inventory file"</span>
|
||||
<span style="color:#66d9ef">from</span>: ansible
|
||||
<span style="color:#66d9ef">to</span>: <span style="color:#e6db74">"{{ recipient }}"</span>
|
||||
<span style="color:#75715e">#body: "{{ mail_body.stdout_lines }}"</span>
|
||||
<span style="color:#66d9ef">attach</span>: <span style="color:#e6db74">"/tmp/{{ ansible_hostname }}_inventory.txt"</span>
|
||||
|
||||
</code></pre></div><p>inventory 內容</p>
|
||||
<pre><code>hqs01.abc.com ansible_ssh_host=192.168.11.1
|
||||
hqs210.abc.com
|
||||
hqs230.abc.com
|
||||
@@ -426,12 +397,8 @@ hqs173.abc.com
|
||||
hqs099.abc.com ansible_ssh_host=192.168.11.99 ansible_ssh_port=22 ansible_ssh_user=root
|
||||
hqs202.abc.com ansible_ssh_host=192.168.11.202 ansible_ssh_port=22 ansible_ssh_user=root
|
||||
bbs089.abc.com ansible_ssh_host=192.168.0.89 ansible_ssh_user=root
|
||||
</code></pre>
|
||||
|
||||
<p>ansible 又發揮了一次,另外,感覺這個指令可以用來寫資產管理系統耶…威力強大</p>
|
||||
|
||||
</code></pre><p>ansible 又發揮了一次,另外,感覺這個指令可以用來寫資產管理系統耶…威力強大</p>
|
||||
<p>而且又不用管作業系統是什麼,反正有執行檔,直接派過去 remote 端就好了!</p>
|
||||
|
||||
<p>真是讓我相見恨晚啊!</p>
|
||||
</article>
|
||||
</div>
|
||||
@@ -711,7 +678,7 @@ title="pinterest icon"></i>
|
||||
|
||||
</ul> <div class="design-credit">
|
||||
|
||||
<p>© 2018 Göran Svensson</p>
|
||||
<p>© 2018 Göran Svensson</p>
|
||||
|
||||
<p>Nederburg Hugo Theme by <a href="https://appernetic.io">Appernetic</a>.</p>
|
||||
|
||||
@@ -723,7 +690,7 @@ title="pinterest icon"></i>
|
||||
</div>
|
||||
<script src="https://h.cowbay.org/js/jquery.min.js"></script>
|
||||
<script src="https://h.cowbay.org/js/jquerymigrate.js"></script>
|
||||
<script src="https://h.cowbay.org/js/production.min.js?v=1626744134"></script>
|
||||
<script src="https://h.cowbay.org/js/production.min.js?v=1629951055"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user