LoginSignup
60
65

More than 5 years have passed since last update.

CoreOS用のcloud-config.ymlを晒しておく

Last updated at Posted at 2014-10-21

etcd/fleet/dockerの自動起動、 TimeZoneのJST化、固定IP化、ユーザ作成(ssh鍵2つ入り)ができるcloud-config.ymlを晒します

cloud-config.yml
#cloud-config

hostname: coreos01

coreos:
  update:
    reboot-strategy: best-effort
  etcd:
    discovery: https://discovery.etcd.io/{HASH}
    addr: 10.200.0.66:4001
    peer-addr: 10.200.0.66:7001
    bind-addr: 0.0.0.0
  fleet:
    public_ip: 10.200.0.66
  units:
    - name: etcd.service
      command: start
    - name: fleet.service
      command: start
    - name: docker.service
      command: start
    - name: timezone.service
      command: start
      content: |
        [Unit]
        Description=timezone
        [Service]
        Type=oneshot
        RemainAfterExit=yes
        ExecStart=/usr/bin/ln -sf ../usr/share/zoneinfo/Japan /etc/localtime
    - name: 10-static.network
      runtime: no
      content: |
        [Match]
        Name=eth0

        [Network]
        Address=10.200.0.66/24
        Gateway=10.200.0.1
        DNS=10.200.0.2
        DNS=10.200.0.3

users:
  - name: coreuser1
    passwd: `openssl passwd -1`
    groups:
      - sudo
      - docker
    ssh-authorized-keys:
      - ssh-rsa AAAA...68= user1@example.jp
      - ssh-rsa AAAA...3h1= user2@example.jp

※10/22: コメントでのアドバイスを基に変更

users.passwdは、openssl passwd -1の結果を貼り付けてください。それ以外にもmkpasswdやperl/pythonを使う方法があるようです

{HASH}は https://coreos.com/docs/cluster-management/setup/cluster-discovery/ を見て得るか、自前でetcdサーバを立てた時のものを使ってください

cloud-config.ymlのデバッグ方法

coreos-cloudinitコマンドが利用できます

$ sudo coreos-cloudinit -from-file=./cloud-config.yml

現在のOS設定がcloud-config.ymlの内容に書き換わっちゃうので要注意

参考資料

あとがき

まぁ、こんなもんか

60
65
2

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
60
65