Join 1M+ other developers and:
- Get help and share knowledge in Q&A
- Subscribe to topics of interest
- Get courses & tools that help you grow as a developer or small business owner
Issues with cloud-config on CentOS 7
I’m trying to use a cloud-config.yml file to automatically configure a few basic tasks when I provision a new droplet, currently though only some steps work, others partly work, and others fail completely and looking at /var/log/clioud-init.log and /var/log/cloud-init-output.log I’m not really sure why it’s failing.
#cloud-config packages: - zsh - vim-enhanced users: - name: jsmith groups: wheel shell: /usr/bin/zsh sudo: ['ALL=(ALL) NOPASSWD:ALL'] ssh_authorized_keys: - (my ssh key) chpasswd: list: | jsmith:(password sanitized) expire: False write_files: - path: /home/jsmith/.my.cnf owner: "jsmith:jsmith" permissions: 0400 content: | [client] user=root password='' runcmd: - [ sed, -i, -e, 's/#PermitRootLogin yes/PermitRootLogin no/g', /etc/ssh/sshd_config ] - systemctl restart sshd
For the above script only the users section runs fully, so I have a user account created trying to use a shell that failed to get installed for it login shell, I can not tell if the chpasswd failed or not as I can’t login due to ZSH failing to get installed by cloud-init. The write_files command partly works, the only thing that fails is it fails to correctly chown the file after creation (probably due to how it’s quoted?). The runcmd hook the sed command does fail, but I’m not sure if the systemcl call failed (I could have checked it’s logs to see if it was restarted but kind of lower priority to the other things).
Anyone with more experience with working with cloud-config know what I’m doing wrong or what’s going on?
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.×