在cloud-config中设置一个可用于systemd服务执行的全局variables

我正在关注系统环境和DefaultEnvironment来设置全局variables

我想通过cloud-config文件configurationdocker和etcd2服务

write_files: - path: /etc/systemd/system.conf.d/10-default-env.conf content: | [Manager] DefaultEnvironment=IP=192.168.0.1 units: - name: docker.service drop-ins: - name: 50-docker.conf content: | [Service] ExecStartPre=/usr/bin/docker daemon -H fd:// --bip=${IP}/24 - name: etcd2.service drop-ins: - name: 20-etcd2.conf content: | [Unit] After=docker.service [Service] ExecStartPre=/usr/lib/coreos/etcd-wrapper \ --name="demo-etcd-1" \ --listen-peer-urls="http://0.0.0.0:2380" \ --listen-client-urls="http://${IP}:4001,http://0.0.0.0:4001,http://${IP}:2379,http://0.0.0.0:2379" \ --initial-advertise-peer-urls="http://http://10.240.0.1:2380" \ --initial-cluster="demo-etcd-1=http://10.240.0.1:2380,demo-etcd-2=http://10.240.0.2:2380,demo-etcd-3=http://10.240.0.3:2380" \ --initial-cluster-state="new" \ --initial-cluster-token="demo-etcd-token" \ --advertise-client-urls="http://10.240.0.1:2379" 

在docker.service上启动失败

 cat 50-docker.conf [Service] ExecStartPre=/usr/bin/docker daemon -H fd:// --bip=${IP}/24 

IPvariables的占位符未被值replace

我也试过,但没有为我工作