2013-12-16 69 views
1

我有我加載與我的VM下雲的init腳本:用戶創建與雲初始化

#cloud-config 
# Add groups to the system 
# The following example adds the ubuntu group with members foo and bar and 
# the group cloud-users. 
groups: 
    - ugroup 

# Add users to the system. Users are added after groups are added. 
users: 
    - default 
    - name: user 
    gecos: Testbed as a Service 
    primary-group: ugroup 
    groups: admin 
    passwd: $6$rounds=4096$4pFvtqM5ldfLzR0hE9r7XSOoCO22lN7OB49IopWQ7SQrB5GBTR8X8okMpxXXQZ0jqUOuy4wKY.iYzwQTo7vH6zKx0DqjTFe6jh1 

runcmd: 
    - [passwd, user, '-u'] 

但它接縫,我做soemthing錯誤

因爲我得到出現以下錯誤:

passwd: user 'user' does not exist 
run-parts: /var/lib/cloud/instance/scripts/runcmd exited with return code 1 
2013-12-16 15:15:09,028 - cc_scripts_user.py[WARNING]: failed to run-parts in /var/lib/cloud/instance/scripts 
2013-12-16 15:15:09,087 - __init__.py[WARNING]: Traceback (most recent call last): 
    File "/usr/lib/python2.7/dist-packages/cloudinit/CloudConfig/__init__.py", line 108, in run_cc_modules 
    cc.handle(name, run_args, freq=freq) 
    File "/usr/lib/python2.7/dist-packages/cloudinit/CloudConfig/__init__.py", line 72, in handle 
    [ name, self.cfg, self.cloud, cloudinit.log, args ]) 
    File "/usr/lib/python2.7/dist-packages/cloudinit/__init__.py", line 309, in sem_and_run 
    func(*args) 
    File "/usr/lib/python2.7/dist-packages/cloudinit/CloudConfig/cc_scripts_user.py", line 27, in handle 
    util.runparts(runparts_path) 
    File "/usr/lib/python2.7/dist-packages/cloudinit/util.py", line 140, in runparts 
    raise subprocess.CalledProcessError(sp.returncode,cmd) 
CalledProcessError: Command '['run-parts', '--regex', '.*', '/var/lib/cloud/instance/scripts']' returned non-zero exit status 1 

2013-12-16 15:15:09,100 - __init__.py[ERROR]: config handling of scripts-user, None, [] failed 

我的問題的任何提示或解決方案?

+0

這似乎是你添加用戶「用戶」,而不是「塔斯」。 –

+0

對不起,我正在編輯文本,並跳過了這一個,我終於解決了這個問題,問題是創建映像的網絡沒有訪問cloud-init服務/ apis。 – VicoMan

回答

1

我意識到這個問題很老,但我確實運行了一個測試,以驗證它在當前的16.04 Ubuntu映像中正常工作。

lxd可用於快速創建實例並測試雲初始化配置。假設你已經LXD成立,我所做的:

$ cat ud.yaml 
#cloud-config 
# Add groups to the system 
# The following example adds the ubuntu group with members foo and bar and 
# the group cloud-users. 
groups: 
    - ugroup 

# Add users to the system. Users are added after groups are added. 
users: 
    - default 
    - name: user 
    gecos: Testbed as a Service 
    primary-group: ugroup 
    groups: admin 
    passwd: $6$rounds=4096$4pFvtqM5ldfLzR0hE9r7XSOoCO22lN7OB49IopWQ7SQrB5GBTR8X8okMpxXXQZ0jqUOuy4wKY.iYzwQTo7vH6zKx0DqjTFe6jh1 

runcmd: 
    - [passwd, user, '-u'] 

$ lxc launch ubuntu-daily:xenial xuser-test \ 
    "--config=user.user-data=$(cat ud.yaml)" 

$ lxc exec xuser-test /bin/bash 

# ls -l /home/ 
total 2 
drwxr-xr-x 3 ubuntu ubuntu 6 Jul 18 18:47 ubuntu 
drwxr-xr-x 2 user ugroup 5 Jul 18 18:47 user 

# tail -n 2 /etc/group 
ugroup:x:1000: 
ubuntu:x:1001: 

# tail -n 2 /etc/passwd 
ubuntu:x:1000:1001:Ubuntu:/home/ubuntu:/bin/bash 
user:x:1001:1000:Testbed as a Service:/home/user: 

# grep passwd /var/log/cloud-init-output.log 
passwd: password expiry information changed. 

如果這仍然是你的問題,請file a bug對雲計算的初始化。