update some content

This commit is contained in:
2021-10-28 14:13:06 +08:00
parent 97eb780aa4
commit 4f99455d8f
242 changed files with 1826 additions and 2616 deletions

View File

@@ -13,7 +13,7 @@
"articleSection" : "post",
"name" : "[筆記] 為了保存log 用script 指令執行ansible \/ Another Way to Keep Ansible Log using script command",
"headline" : "[筆記] 為了保存log 用script 指令執行ansible \/ Another Way to Keep Ansible Log using script command",
"description" : "\x3cp\x3e之前為了能夠在執行完 ansible playbook 後能有個log 可以看\x3c\/p\x3e\n\x3cp\x3e所以在每次執行的時候都要加入 tee 的指令\x3c\/p\x3e\n\x3cp\x3e像是\x3c\/p\x3e\n\x3cpre\x3e\x3ccode\x3eANSIBLE_CONFIG=\/home\/D\/ansiblecontrol\/ansible.cfg \/usr\/local\/bin\/ansible-playbook \/home\/D\/ansiblecontrol\/playbook.user_client.yml --vault-password-file=\/home\/D\/ansiblecontrol\/vault.passwd -i \/home\/D\/ansiblecontrol\/inventory\/production -f1 --limit tyuserclients |tee \/tmp\/tyuserclients.log\n\x3c\/code\x3e\x3c\/pre\x3e\x3cp\x3e一直都是放在crontab 裡面執行,也就沒有去管他\x3c\/p\x3e\n\x3cp\x3e反正也沒有人關心結果怎樣 (攤手\x3c\/p\x3e",
"description" : "\u003cp\u003e之前為了能夠在執行完 ansible playbook 後能有個log 可以看\u003c\/p\u003e\n\u003cp\u003e所以在每次執行的時候都要加入 tee 的指令\u003c\/p\u003e\n\u003cp\u003e像是\u003c\/p\u003e\n\u003cpre tabindex=\u00220\u0022\u003e\u003ccode\u003eANSIBLE_CONFIG=\/home\/D\/ansiblecontrol\/ansible.cfg \/usr\/local\/bin\/ansible-playbook \/home\/D\/ansiblecontrol\/playbook.user_client.yml --vault-password-file=\/home\/D\/ansiblecontrol\/vault.passwd -i \/home\/D\/ansiblecontrol\/inventory\/production -f1 --limit tyuserclients |tee \/tmp\/tyuserclients.log\n\u003c\/code\u003e\u003c\/pre\u003e\u003cp\u003e一直都是放在crontab 裡面執行,也就沒有去管他\u003c\/p\u003e\n\u003cp\u003e反正也沒有人關心結果怎樣 (攤手\u003c\/p\u003e",
"inLanguage" : "en",
"author" : "Eric Chang",
"creator" : "Eric Chang",
@@ -21,8 +21,8 @@
"accountablePerson" : "Eric Chang",
"copyrightHolder" : "Eric Chang",
"copyrightYear" : "2019",
"datePublished": "2019-08-05 16:24:40 \x2b0800 CST",
"dateModified" : "2019-08-05 16:24:40 \x2b0800 CST",
"datePublished": "2019-08-05 16:24:40 \u002b0800 CST",
"dateModified" : "2019-08-05 16:24:40 \u002b0800 CST",
"url" : "https:\/\/h.cowbay.org\/post\/another-way-to-keep-ansible-log\/",
"wordCount" : "43",
"image" : "https://h.cowbay.orghttps://h.cowbay.org/images/post-default-10.jpg"",
@@ -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=1632901488" rel="stylesheet" id="theme-stylesheet" type='text/css' media='all'>
<link href="https://h.cowbay.org/css/style.css?v=1634607506" rel="stylesheet" id="theme-stylesheet" type='text/css' media='all'>
<link href="https://h.cowbay.org/css/custom.css?v=1632901488" rel="stylesheet" type='text/css' media='all'>
<link href="https://h.cowbay.org/css/custom.css?v=1634607506" 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">
@@ -307,12 +307,12 @@ if (!doNotTrack) {
<p>之前為了能夠在執行完 ansible playbook 後能有個log 可以看</p>
<p>所以在每次執行的時候,都要加入 tee 的指令</p>
<p>像是</p>
<pre><code>ANSIBLE_CONFIG=/home/D/ansiblecontrol/ansible.cfg /usr/local/bin/ansible-playbook /home/D/ansiblecontrol/playbook.user_client.yml --vault-password-file=/home/D/ansiblecontrol/vault.passwd -i /home/D/ansiblecontrol/inventory/production -f1 --limit tyuserclients |tee /tmp/tyuserclients.log
<pre tabindex="0"><code>ANSIBLE_CONFIG=/home/D/ansiblecontrol/ansible.cfg /usr/local/bin/ansible-playbook /home/D/ansiblecontrol/playbook.user_client.yml --vault-password-file=/home/D/ansiblecontrol/vault.passwd -i /home/D/ansiblecontrol/inventory/production -f1 --limit tyuserclients |tee /tmp/tyuserclients.log
</code></pre><p>一直都是放在crontab 裡面執行,也就沒有去管他</p>
<p>反正也沒有人關心結果怎樣 (攤手</p>
<p>後來發現有個指令叫 script 可以完整紀錄指令執行期間的console 畫面變化(包含了ansi color!)</p>
<p>剛剛測試了一下,發現的確是可以用,不過也沒感覺有特別好用的地方,就只是做個紀錄吧,說不定以後其他地方可以用得到</p>
<pre><code>sciprt -c 'make EXTRA_ARGS=&quot;-i inventory/production --limit hqpc074&quot; user_client' -f hqpc074.out'
<pre tabindex="0"><code>sciprt -c 'make EXTRA_ARGS=&quot;-i inventory/production --limit hqpc074&quot; user_client' -f hqpc074.out'
</code></pre><p>結果長這樣
<img src="https://i.imgur.com/F9KFAWV.png" alt=""></p>
<p>就真的跟console 的畫面一樣</p>
@@ -602,7 +602,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=1632901488"></script>
<script src="https://h.cowbay.org/js/production.min.js?v=1634607506"></script>
</body>
</html>