LoginSignup
2
2

More than 5 years have passed since last update.

Ignitionファイルへの変換ツール Container Linux Config Transpiler(ct)インストール

Posted at

本記事は Container Linux Config Transpiler(ct) の導入についての備忘録です。

前書き

Container Linux では Ignition というプロビジョニングユーティリティを使用して初期設定を行います。
Ignition は初回起動時のみに適用されるJSON形式のファイルとなります。

ただ Ignition ファイルの作成は人に優しくない苦行になってしまうため、

  1. 人に優しいYAML形式である Container Linux Config ファイルを書く
  2. Container Linux Config Transpiler(ct) を使用して Ignition ファイル(jsonファイル)に変換する

という手順がセオリーになります。

今回は ct のインストール方法と簡単な使い方について説明していきます。

  • 導入環境

    システム バージョン
    Windows10 Pro x64 1709
    opesSUSE (WSL) Leap 42.3

ct インストール

バイナリが配布されているため、これをダウンロードしてパスを通せばいいだけです。

GitHubのREADMEにそのものズバリな手順も書かれていますが、備忘録ということで自分がやった手順も残しておきます。

以下、WSLの openSUSE 上で作業しています。

  1. CoreOSのアプリ用公開鍵のインポート

    bash
    curl -s https://coreos.com/dist/pubkeys/app-signing-pubkey.gpg | gpg --import
    
  2. ct のバイナリファイルをダウンロード

    bash
    curl -LO https://github.com/coreos/container-linux-config-transpiler/releases/download/v0.9.0/ct- 
    v0.9.0-x86_64-unknown-linux-gnu
    
  3. 署名確認

    bash
    $ curl -LO https://github.com/coreos/container-linux-config-transpiler/releases/download/v0.9.0/ct-v0.9.0-x86_64-unknown-linux-gnu.asc
    $ gpg --verify ct-v0.9.0-x86_64-unknown-linux-gnu.asc
    
    gpg: assuming signed data in 'ct-v0.9.0-x86_64-unknown-linux-gnu'
    gpg: Signature made Sat 19 May 2018 08:42:52 AM DST
    gpg:                using RSA key 9CEB8FE6B4F1E9E752F61C82CDDE268EBB729EC7
    gpg: Good signature from "CoreOS Application Signing Key <security@coreos.com>" [unknown]
    gpg: WARNING: This key is not certified with a trusted signature!
    gpg:          There is no indication that the signature belongs to the owner.
    Primary key fingerprint: 18AD 5014 C99E F7E3 BA5F  6CE9 50BD D3E0 FC8A 365E
         Subkey fingerprint: 9CEB 8FE6 B4F1 E9E7 52F6  1C82 CDDE 268E BB72 9EC7
    
  4. パス通し

    bash
    chmod 755 ct-v0.9.0-x86_64-unknown-linux-gnu
    sudo mv ct-v0.9.0-x86_64-unknown-linux-gnu /usr/local/bin/
    cd /usr/local/bin
    sudo ln -s ct-v0.9.0-x86_64-unknown-linux-gnu ct
    

これで ct コマンドが使えるようになります。

使い方

Container Linux Config を読み込ませるとJSON形式に変換して標準出力してくれます。

bash
$ ct < clconf.yml

{"ignition":{"config":{},"security":{"tls":{}},"timeouts":{},"version":"2.2.0"},"networkd":{},"passwd":{"users":[{"homeDir":"/home/hoge","name":"hoge","sshAuthorizedKeys":["ssh-rsa xxx..."],"shell":"/bin/bash"}]},"storage":{},"systemd":{}}

よって Ignition ファイルを作成するにはリダイレクトすればOKです。

bash
ct < clconf.yml > ignition.ign

また、設定に誤りがあると次のようなエラー出力がなされます。

bash
$ ct < wrong_clconf.yml > ignition.ign

error: yaml: line 7: did not find expected '-' indicator
Failed to parse config

以上で Container Linux Config Transpiler の導入は終わりです。お疲れ様でした。

今回は説明しなかった Container Linux Config ファイルの書き方についてはまた別記事で書いてみる予定です。
(公式ドキュメントにある Examples の焼き写しになりますが……)

参考

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2