Gcloud CoreOs Cloud Config 没有生效

Gcloud CoreOs Cloud Config not having effect

我正在尝试在 google 云上创建一个 coreos 实例,它似乎忽略了我的云配置

这是我设置 gcloud coreos 实例的终端命令。

gcloud compute instances create gfb-core-1 --zone europe-west1-b --machine-type n1-standard-1 --metadata-from-file user-data=conductor/coreos/cloud-config-gcloud.ym

下面是我的云配置示例。

    #cloud-config
      coreos:
        units:
          - name: sample.service
            command: start
            enable: true
            content: |
              [Unit]
              Description=Sample Service.
              After=docker.service
              Requires=docker.service

              [Service]
              TimeoutStartSec=0
              EnvironmentFile=/etc/environment
              ExecStart=/opt/bin/docker-compose start;
              ExecStop=/opt/bin/docker-compose stop;

              [Install]
              WantedBy=multi-user.target
          - name: backup.service
            enable: true
            content: |
              [Unit]
              Description=Sample BackUp Script

              [Service]
              Type=oneshot
              ExecStart=/usr/bin/docker exec db-live /backup-db.sh
          - name: backup.timer
            command: start
            enable: true
            content: |
              [Unit]
              Description=Runs Sample BackUp twice a day

              [Timer]
              OnCalendar=*-*-* 0/12:00:00
              # References for timers https://www.freedesktop.org/software/systemd/man/systemd.time.html# units:
          - name: media-backup.mount
            command: start
            enable: true
            content: |
              [Mount]
              What=/dev/disk/by-id/google-core-disk-1
              Where=/app
              Type=ext3
      write_files:
        - path: /etc/environment
          permissions: 420
          content: |
            COMPOSE_FILE=/path/to/app/docker-compose.yml
        - path: /home/core/.bashrc
          permissions: 420
          owner: core:core
          content: |
            # source <(sudo cat /etc/environment)
            eval $(sudo cat /etc/environment | sed 's/^/export /')

Cloud-configs 对 structure/hierarchy 使用了缩进,您共享的文件的意图不正确。这是分享的错字还是真的是这样?

试试 https://coreos.com/validate/ 看看你的配置是否有效。