Packer

是 HashiCorp 釋出的一個工具,它可以依照寫好的設定檔,打包各種格式的 image,像 Amazon Machine Image (給 EC2 用)、Virtualbox iso/ovf、digital ocean、docker、openstack、vmware iso/vmx、Vagrant box …. 等等。安裝很簡單,就下載 zip ,解壓縮 (Linux 下要改權限) 放到路徑裡就可以使用了。

第一次撰寫可以參考 https://github.com/shiguredo/packer-templates 這裡的設定檔範例。指令的使用也蠻簡單,例如:只要做 virtualbox 用的 ovf ,packer build -only=virtualbox-iso template.json

一口氣 build 不同格式的 image:packer build -parallel=true template.json

在 provision 的部份,可以用 shell、chef、puppet… 等,也可以用 ansible https://www.packer.io/docs/provisioners/ansible-local.html

打包好的 image ,會自動放在或推到對應的地方,例如 AMI 就會放到 Amazon 那邊,docker image 可以推送到 docker registry,digital ocean 就是 droplet 或者是推送到 vagrant 等等。

Terminal 下的複製與貼上

複製與貼上是透過 xsel 指令,例如:

    • 複製到剪貼簿:xsel –clipboard < your_file
    • 將內容輸出到指定檔案: xsel –clipboard > your_new_file
    • 將指定字串放到剪貼簿裡:echo “your_text” | xsel –clipboard

如果連線到遠端,也可以使用,但是 ssh 連線時,必須加上 -Y 參數,或是在設定檔裡加上 ForwardX11 yes 跟 ForwardX11Trusted yes 。

另外再介紹 parcellite,這是一個剪貼簿的管理程式,類似 Windows 的 ditto。在啟動以後,按下 ctrl+alt+h 就可以叫出來,這時可以看到剪貼簿的過往紀錄。

參考資料:

Python InsecurePlatformWarning

碰到這個歡樂的錯誤,其實已經碰過兩三次了,前面幾次都不了了之。

InsecurePlatformWarning: A true SSLContext object is not available.

這次是確實的找到方法可以不用改程式避掉的方法,方法很簡單,就是安裝 pyopenssl ndg-httpsclient pyasn1 這幾個模組,這幾個模組會自動將 SSL 相關的憑證注射到 urllib3 模組裡,下載時就不會有 InsecurePlatformWarning 的警告。

這方法是在 StackOverflow 的 python – InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately 看到解法的,感謝。

git clone fail

遇到下面這錯誤~

$ git clone http://your_host/your_group/your_project.git
Cloning into 'your_project'...
remote: Counting objects: 426, done.
remote: Compressing objects: 100% (375/375), done.
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed

過程大致就如 gitlab – error: git-upload-pack died of signal 13 – Stack Overflow

所以我試過 git config –global http.postBuffer 524288000 ,也試著加過 GIT_CURL_VERBOSE ,但都看不出什麼端倪,伺服器上的 log 也沒看到,最後就如 gitlab – error: git-upload-pack died of signal 13 – Stack Overflow 的解答所說,是 permission 問題。我猜可能是我有調整 nginx user 的關係,導致錯誤。後來就是依據 log 裡的提示,調整 /var/run/nginx/proxy 下資料夾的 owner 就解決問題了。