"MCの部落"

Skip to content

[筆記] 為了保存log 用script 指令執行ansible / Another Way to Keep Ansible Log using script command

Posted bychchang 2020-06-28 Leave a comment on [筆記] 為了保存log 用script 指令執行ansible / Another Way to Keep Ansible Log using script command

之前為了能夠在執行完 ansible playbook 後,能有個log 可以看

所以在每次執行的時候,都要加入 tee 的指令

像是

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

一直都是放在crontab 裡面執行,也就沒有去管他

反正也沒有人關心結果怎樣 (攤手

後來發現有個指令叫 script 可以完整紀錄指令執行期間的console 畫面變化(包含了ansi color!)

剛剛測試了一下,發現的確是可以用,不過也沒感覺有特別好用的地方,就只是做個紀錄吧,說不定以後其他地方可以用得到

sciprt -c 'make EXTRA_ARGS="-i inventory/production --limit hqpc074" user_client' -f hqpc074.out'

結果長這樣

就真的跟console 的畫面一樣

Tags: a, ansible, cloudflare, debian, docker, GPU, letsencrypt, n1, openwrt, pihole, postfix, postgresql, raid, router, ssl, synology, ubuntu, vpn, wireguard,

文章導覽

Previous Post Previous post:
[筆記] 在ubuntu 18.04中,透過 dconf 設定系統層級的「我的最愛」/ Add System Wide Favorite Apps in dock with Dconf in ubuntu 18.04
Next Post Next post:
[筆記]在ansible中,取得loop register後的值/ Ansible Get Value From Loop Register

No comments

Write a Reply or Comment 取消回覆

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

You May Also Like:

[筆記] ansible 設定 ssh_args 開啟 ForwardX11 / config ansible ssh_args to enable forwardagent
[ansible] Ansible how to use ‘list’ in yaml file
[ansible] 引用事先定義好的yaml檔裡面的變數 – Ansible Selectattr From List in Dictionary file
[筆記] 還是 Ansible Selectattr

"MCの部落"

Top