178 Commits
Author SHA1 Message Date
jwang 4706d35c2c Add aliyun cloud support
Enable ucd to work in aliyun cloud by add a config templete
for aliyun

Signed-off-by: jwang <jing.j.wang@intel.com>
2019-10-15 11:27:02 -07:00
Auke Kok 542b611ae1 user-data: allow missing user data.
When I deduplicated this code I mistakenly used parse_headers() in
the same way twice. This was incorrect.

We definitely need to error out if a 404 or something else happens
for the SSH keys, since then we've lost entirely.

But a missing `user-data` is mostly harmless and optional, so, in
case a 404 happens for the second `GET` request, we shouldn't error
out, because this makes the instance unusable. Instead, we can
carry on as normal.
2019-09-30 10:58:24 -07:00
Auke Kok a240a29d21 Fix typo in yaml tag for ssh_authorized_keys. 2019-09-30 10:58:24 -07:00
jwang 7ed37b2b41 fix typo in tencent cloud-config template 2019-09-24 20:55:25 -07:00
Auke Kok 922b303f1b Don't create an abbreviated AWS user-data. 2019-09-23 10:09:46 -07:00
jwang 2c7059fa5d fix wrong retcode check for write_lines function
write_lines return 0 means succeed, thus !write_lines go into error
handling path, which is not expected.

Signed-off-by: jwang <jing.j.wang@intel.com>
2019-09-12 10:47:53 -07:00
Auke Kok d2451d23ec Create write_lines() function to replace problematic duplicate code.
Create a new function for both sections of code needing to output
remainder stream bytes into output file. This makes error handling simpler
and easier to focus on the errors here in tencent.

I've adapted the code to use the OCI model of outputting the needed
data since OCI code written by William handles the output slightly
different based on previous experiences with OCI and I think this may
just help the Tencent case as well.

Also change some types to reduce casting. All in all this slightly
cleans up the code a bit.
2019-08-16 13:01:13 -07:00
Auke Kok 51e7f96ba3 Catch empty user_data file - nothing possible to do. 2019-08-15 16:11:17 -07:00
Auke Kok 57c3c60066 Check return value of write(). 2019-08-15 15:04:42 -07:00
Auke Kok d54043ce45 Handle write() exception. 2019-08-15 14:47:14 -07:00
Auke Kok 160ec7394e Don't run strlen() if buf is NULL.
Change the order here to make sure we're not running strlen
for no reason.
2019-08-15 14:05:31 -07:00
Auke Kok bdad5c2818 Update man pages to reflect the ucd-data-fetch program. 2019-08-07 14:59:30 -07:00
Auke Kok 01d4102d99 ucd-data-fetch: Support HTTP/1.1, allow HTTP/1.0 responses.
We do not want to break anything where HTTP/1.0 is only supported,
so we advertise 1.1 but allow responses from 1.0 capable server
as well as 1.1 capable servers.
2019-08-07 13:29:32 -07:00
Auke Kok 31e30b5b29 Start of unification of aws/oci/tencent data fetcher.
Instead of keep duplicating existing code, we can make this program
a little bit more versatile and cover all 3 use cases and add some
extensibility for further additions.

A static table describes what needs fetching and from where. The
rest is logically the same and so the delta isn't so bad.

We add tencent cloud support on top of this.
2019-08-06 15:29:12 -07:00
Julio Montes b1073ea8d4 disk: maximize rootfs partition
Other cloud-config implementations like cloud-init resizes automatically the
rootfs to the maximum allowed, ucd should do the same.

fixes #34

Signed-off-by: Julio Montes <julio.montes@intel.com>
2019-04-11 23:18:28 +02:00
Auke Kok 365393bd31 Memset struct sockaddr_in to zero. 2018-11-16 10:48:57 -08:00
Auke Kok dc803bd6aa Fix dead code branch on error condition. 2018-11-16 09:44:46 -08:00
Auke Kok bfc2d427be AWS: Do not assume the HTTP server supports keep-alive.
On some of the computational AWS instances, the HTTP service at
169.254* does not support HTTP/1.0 keep-alive. This causes the
second part of the user-data not to be transferred and results
in an error during the execution of ucd-aws. Subsequently, the
SSH key never gets provisioned by `ucd`. The result is an unusable
AWS instance that can't be remotely logged into.

Instead, we just terminate and reconnect for the second HTTP
request, reusing some memory where we can. This is a minute
bit slower, and doesn't really come at a size penalty either,
since it's just the same functions being used.
2018-09-06 09:26:29 -07:00
Auke Kok 58f50b83c8 Do not run initial setup async.
Since we have another task also run `usermod` as well, these
might bump into a lock file for /etc/ files and fail, leaving
the system unable to login a normal user.
2018-08-09 14:24:02 -07:00
William Douglas abe84ebe5d Fix logic for testing HTTP errors
Change to test if HTTP code is < 200 or > 299 rather than being both <
200 and > 299.
2018-05-14 15:05:49 -07:00
William Douglas bfadb7b09f Add Oracle Cloud support
Enable ucd to work within the Oracle Cloud environment. In this case
it involves creating the opc user and provisioning the ssh public
key.
2018-05-14 15:05:49 -07:00
Auke Kok 7e7755ac37 Fix typo (wiht->with) 2017-11-13 10:45:45 -08:00
Auke Kok 3784aea67a meta-data: process public_keys
This adds support for parsing openstack meta-data.json files in
config-2 filesystems and extracting and installing any SSH pubkeys
into the default user account.

In order to properly parse a config-2 json blob outside of the normal
openstack early initialization, we need to fill the parser table
properly and clean it up.

This exposes some flaws in other parts of this code that appear that
this wasn't entirely fully tested. I have not yet confirmed that
in a config-2 scenario everything actually automatically works yet,
this remains to be done.
2017-06-30 12:31:56 -07:00
Auke Kok 9d13049eb3 Fetch both ssh key and userdata in one http conversation. 2017-05-05 15:34:52 -07:00
Auke Kok 5056dc93ef Do not hard code path to ucd binary, instead pass $bindir 2017-05-02 10:28:21 -07:00
Auke Kok 5531716c67 Makedev will be in <sys/sysmacros.h>. 2017-05-02 10:10:46 -07:00
Auke Kok 4e21debad3 Convert to agreed upon code style for braces. 2017-05-02 10:08:50 -07:00
Auke Kok 5f80692011 ucd AWS helper.
The ucd-aws program fetches the user-data for an AMI instance
over http from 169.254.169.254, and passes it back to ucd.

The service is not supposed to be enabled unless you are running
on AWS, as it is highly specific to that cloud.
2017-04-28 14:48:10 -07:00
Ikey Doherty 574c759b30 lib: Ensure pwd_buf is always freed in write_ssh_keys
Prior to this change, a NULL pw_dir would result in pwd_buf being leaked after
write_ssh_keys is called. Granted, it's a minor leak, and only potential, but
should still be fixed regardless.

Signed-off-by: Ikey Doherty <michael.i.doherty@intel.com>
2016-07-27 14:43:52 -07:00
Ikey Doherty 2c7ba9a934 Replace all instances of clr-cloud-init with micro-config-drive
The project has been renamed from clr-cloud-init to clearly communicate the
scope and target of the project. This change simply ensures all the source
files are now consistent in their agreement of the project name.

The (C) usage was also swapped for ©, simply because it is the proper symbol
and looks better.

Signed-off-by: Ikey Doherty <michael.i.doherty@intel.com>
2016-07-27 14:43:52 -07:00
Julio Montes b4fec921d3 remove network code (#21)
* remove no-network option

Signed-off-by: Julio Montes <julio.montes@intel.com>

* update documentation

Signed-off-by: Julio Montes <julio.montes@intel.com>

* update service files

Signed-off-by: Julio Montes <julio.montes@intel.com>
2016-06-22 15:11:59 -07:00
Auke Kok f9f2dd5b9f Remove CURL support entirely. (#20)
With this change, only config-drive is effectively supported.
2016-06-09 11:33:23 -07:00
Divya Thaluru 087eb25308 Added tdnf package manager (#16) 2016-05-19 10:37:25 -07:00
dthaluru 427736cf72 Updated yum package manager
Added assumeyes as additional argument to yum install command
to automatically answer interactive questions as 'yes'
2016-05-18 11:56:34 -07:00
Auke Kok 45b46affd6 Allow package manager selection.
Supported package managers are: swupd (default), yum, dnf, apt.

If configure is passwd --with-packagemgr=<pkgmgr>, then the appropriate
calls to dnf/yum etc. are used instead of `swupd`. This affects the
`packge_upgrade' and `packages' directives, exclusively.

This is determined at compile time, without checking for dependencies
being actually present. This seems preferable than to try and determine
at runtime what support is present.
2016-05-12 14:30:46 -07:00
Julio Montes a102bba258 auto-prepend username to sudo directives
update users.yaml example
2016-05-11 11:23:27 -05:00
Julio Montes 73d1aeb4ea add outdir parameter to curl_fetch_file
files downloaded by curl can be saved in
a safe directory
2016-04-21 14:27:22 -05:00
Julio Montes 5dddbbdc44 Use clr-cloud-init's datadir instead of /tmp to process data 2016-04-21 13:50:45 -05:00
Julio Montes 5218ce78cf use GHashTable to get and run metadata handlers 2016-04-19 12:05:20 -05:00
Julio Montes 3d5ac4b6b7 fix copy user data file 2016-04-15 16:49:03 -05:00
Julio Montes e3a5bf3eab Process openstack user data once per boot 2016-04-15 16:10:20 -05:00
Julio Montes 9023f624fb add cache to get_boot_id 2016-04-15 16:00:45 -05:00
Julio Montes f278175f6d Process openstack metadata once per boot 2016-04-15 15:53:08 -05:00
Julio Montes 08bf9f07cc add function to get boot id
implement get_boot_id function
2016-04-15 14:42:26 -05:00
Julio Montes aae98b9af5 change default user password when it already exists 2016-04-15 11:54:34 -05:00
Julio Montes b99c8494b8 Fix repeated sudo directives in sudoers files 2016-04-15 11:44:54 -05:00
Julio Montes c9748e3350 add condition to create default user account once 2016-04-15 11:31:29 -05:00
Julio Montes 55db5e865f fix userdata file not found 2016-04-15 10:30:19 -05:00
Julio Montes fa3099504f fix g_strlcpy assertion when userdata is not found 2016-04-15 10:26:40 -05:00
Julio Montes 2d4e5d2cdc Add cache in is_first_boot to improve performance 2016-04-15 09:03:28 -05:00