模板不会生成我在云配置中设置的竹子用户。我ssh到我的集群,看到cat / etc / passwd,但我没有看到该用户。可能出现什么问题?
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "CoreOS on EC2: http://coreos.com/docs/running-coreos/cloud-providers/ec2/",
"Mappings" : {
"RegionMap" : {
"us-west-2" : {
"AMI" : "ami-06af7f66"
}
}
},
"Parameters": {
"InstanceType" : {
"Description" : "EC2 HVM instance type (m3.medium, etc).",
"Type" : "String",
"Default" : "t2.small",
"AllowedValues" : [ "t2.micro", "m3.medium", "i2.4xlarge", "i2.8xlarge", "r3.large", "r3.xlarge", "r3.2xlarge","r3.4xlarge", "r3.8xlarge", "t2.micro", "t2.small", "t2.medium" ],
"ConstraintDescription" : "Must be a valid EC2 HVM instance type."
},
"myVPC": {
"Type": "AWS::EC2::VPC::Id",
"Description": "The VPC Id where the instances will be deployed into."
},
"SecurityGroupId":{
"Type": "List<AWS::EC2::SecurityGroup::Id>",
"Description": "Security group to launch instances into."
},
"SubnetId":{
"Type": "List<AWS::EC2::Subnet::Id>",
"Description": "VPC group to launch instances into."
},
"ClusterSize": {
"Default": "3",
"MinValue": "3",
"MaxValue": "12",
"Description": "Number of nodes in cluster (3-12).",
"Type": "Number"
},
"DiscoveryURL": {
"Description": "An unique etcd cluster discovery URL. Grab a new token from https://discovery.etcd.io/new?size=<your cluster size>",
"Type": "String"
},
"AdvertisedIPAddress": {
"Description": "Use 'private' if your etcd cluster is within one region or 'public' if it spans regions or cloud providers.",
"Default": "private",
"AllowedValues": ["private", "public"],
"Type": "String"
},
"KeyPair" : {
"Description" : "The name of an EC2 Key Pair to allow SSH access to the instance.",
"Type" : "AWS::EC2::KeyPair::KeyName"
}
},
"Resources": {
"CoreOSServerAutoScale": {
"Type": "AWS::AutoScaling::AutoScalingGroup",
"Properties": {
"LaunchConfigurationName": {"Ref": "CoreOSServerLaunchConfig"},
"VPCZoneIdentifier": {"Ref":"SubnetId"},
"MinSize": "3",
"MaxSize": "12",
"DesiredCapacity": {"Ref": "ClusterSize"},
"Tags": [
{"Key": "Name", "Value": { "Ref" : "AWS::StackName" }, "PropagateAtLaunch": true}
]
}
},
"CoreOSServerLaunchConfig": {
"Type": "AWS::AutoScaling::LaunchConfiguration",
"Properties": {
"ImageId" : { "Fn::FindInMap" : [ "RegionMap", { "Ref" : "AWS::Region" }, "AMI" ]},
"InstanceType": {"Ref": "InstanceType"},
"KeyName": {"Ref": "KeyPair"},
"SecurityGroups": {"Ref": "SecurityGroupId"},
"UserData" : { "Fn::Base64":
{ "Fn::Join": [ "", [
"#cloud-config\n\n",
" users:\n",
" - name: bamboo\n",
" groups:\n",
" - sudo\n",
" - docker\n",
" - fleet\n",
" - systemd\n",
" - wheel\n",
" - bamboo\n",
" ssh-authorized-keys:\n",
" - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDKT3QjGuTD4sdBfKZZm1cOz2gXBH546vGizsDGf3LEQC63QduU1CPQBvTG742H5yVix7y+qvZPTYlvQ1ysK6ezhbGeu+lT0WoI8YT4x2Pqe/F40WGn/SMv3ckELQhKH3gp9HC1z/ITxYVgTksKGGXgNO6G8w8J+XaC1hyYntyOz531GAly9szCxtPQJQCz1fS3fdjSPEM+7TyuwH240S/Aa0R0XGUt24xH4zyifmUjrvGq4AaHIFUyWO3XnEc/3kdA2uUQlV/2o7z9xE0WhYPWm2oReHXNuoOCQutTCYwNKaTI+Y/vGtGxsCmIQWVoY4Afg2nL0MQ1Mnfw3DddQJvB cmbuild@bamboo_agent_fleetctl \n",
"coreos:\n",
" etcd2:\n",
" discovery: ", { "Ref": "DiscoveryURL" }, "\n",
" advertise-client-urls: http://$", { "Ref": "AdvertisedIPAddress" }, "_ipv4:2379\n",
" initial-advertise-peer-urls: http://$", { "Ref": "AdvertisedIPAddress" }, "_ipv4:2380\n",
" listen-client-urls: http://0.0.0.0:2379,http://0.0.0.0:4001\n",
" listen-peer-urls: http://$", { "Ref": "AdvertisedIPAddress" }, "_ipv4:2380\n",
" units:\n",
" - name: etcd2.service\n",
" command: start\n",
" - name: fleet.service\n",
" command: start\n"
] ]
}
}
}
}
}
}
群集已生成且运行良好,但我没有看到该用户。是否有一个地方可以看到日志中没有发生用户生成的原因?
答案 0 :(得分:0)
要回答您的实际问题,您可以使用journalctl --identifier=coreos-cloudinit
您还可以使用online validator或在CoreOS计算机上运行coreos-cloudinit -validate
来验证您的cloud-config。
但是,看看你的配置,你似乎已经过度缩进了users
block。
以下内容应该有效:
#cloud-config
users:
- name: bamboo
groups:
- sudo
- docker
- fleet
- systemd
- wheel
- bamboo
ssh-authorized-keys:
- ssh-rsa <RSA Public Key> cmbuild@bamboo_agent_fleetctl
coreos:
etcd2:
discovery: {Ref":DiscoveryURL" },
advertise-client-urls: http://$ {Ref":AdvertisedIPAddress" },_ipv4:2379
initial-advertise-peer-urls: http://$ {Ref":AdvertisedIPAddress" },_ipv4:2380
listen-client-urls: http://0.0.0.0:2379,http://0.0.0.0:4001
listen-peer-urls: http://$ {Ref":AdvertisedIPAddress" },_ipv4:2380
units:
- name: etcd2.service
command: start
- name: fleet.service
command: start