Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add create_hostname_file to all hostname user-data examples #4727

Merged

Conversation

catmsred
Copy link
Collaborator

@catmsred catmsred commented Jan 2, 2024

If a cloud or user sets create_hostname_file to false (as GCP does) the examples in our docs for setting the hostname will not work. This change updates those examples to also set create_hostname_file to true.

Proposed Commit Message

docs: add create_hostname_file to all hostname user-data examples
    
If a cloud or user sets create_hostname_file to false (as GCP does)
the examples in our docs for setting the hostname will not work.
This change updates those examples to also set create_hostname_file
to true.

Additional Context

See #4330 for details on create_hostname_file key.

Test Steps

This is left as a WIP because I want to go through and follow each of the changed examples to ensure they still work with the new key included.

Checklist

Merge type

  • Squash merge using "Proposed Commit Message"
  • Rebase and merge unique commits. Requires commit messages per-commit each referencing the pull request number (#<PR_NUM>)

Copy link
Member

@holmanb holmanb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @catmsred for this PR. I like the direction of it. I just noticed the WIP tag, but I had already started reviewing so I'll leave what I started below.

Think we want to add this to the modules examples?

@@ -287,6 +287,9 @@ On an Ubuntu system, :file:`/etc/cloud/cloud.cfg` should look similar to:
# This will cause the set+update hostname module to not operate (if true)
preserve_hostname: false

# This will create the hostname file (e.g. /etc/hostname) if it does not already exist (if true)
create_hostname_file: false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why add this?

On an Ubuntu system, :file:/etc/cloud/cloud.cfg should look similar to:

This will only be true on GCE, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point -- will fix! And yes, I think it would be good to add to the modules examples for set and update hostname. Thanks!

@catmsred catmsred force-pushed the docs/update_metadata_hostname branch 2 times, most recently from bff03b9 to b136c51 Compare January 3, 2024 19:44
@@ -216,6 +216,7 @@ Example ``meta-data``
broadcast 192.168.1.255
gateway 192.168.1.254
hostname: myhost
create_hostname_file: true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create_hostname_file isn't valid here. This is meta data, not user data

@@ -338,6 +338,7 @@ this datasource using the GuestInfo keys transport:

instance-id: cloud-vm
local-hostname: cloud-vm
create_hostname_file: true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This key is not valid here. We instead add it to the user data in the block below this one.

cloudinit/config/cc_set_hostname.py Outdated Show resolved Hide resolved
@@ -22,6 +22,7 @@ EOF
cat << EOF > meta-data
instance-id: someid/somehostname
local-hostname: jammy
create_hostname_file: true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is a tutorial, I think we can remove this line (and probably the line above it) to avoid over-complicating things.

@holmanb , what do you think? Also...where is this file even used/referenced?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is a tutorial, I think we can remove this line (and probably the line above it) to avoid over-complicating things.

+1 works for me

Also...where is this file even used/referenced?

This file is referenced from the Qemu tutorial debugging page.

@@ -144,6 +144,7 @@ Now let's run the following command, which creates a file named
$ cat << EOF > meta-data
instance-id: someid/somehostname
local-hostname: jammy
create_hostname_file: true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. This would go into user data, not meta data. Though...I'm not sure it's worth mentioning hostnames at all.

@blackboxsw blackboxsw added the documentation This Pull Request changes documentation label Jan 9, 2024
@github-actions github-actions bot removed the documentation This Pull Request changes documentation label Jan 18, 2024
@catmsred catmsred force-pushed the docs/update_metadata_hostname branch 2 times, most recently from 0d5d178 to dc56887 Compare January 23, 2024 16:37
Copy link
Member

@TheRealFalcon TheRealFalcon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@catmsred , I'm assuming this is no longer WIP? If so, it's usually best to remove WIP from the title.

@catmsred
Copy link
Collaborator Author

I don't consider it still a WIP but I would like @s-makin to finish her review before it's merged

@catmsred catmsred changed the title [WIP] docs: add create_hostname_file to all hostname user-data examples docs: add create_hostname_file to all hostname user-data examples Jan 24, 2024
@catmsred catmsred requested a review from s-makin January 25, 2024 18:42
Copy link
Member

@holmanb holmanb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that this touches some docs files, but the changes appear code / config related, so I don't think a review from @s-makin is really required (though it would be welcome). Since there hasn't been any response from @s-makin do you mind if we go ahead with a merge on this one @catmsred?

@catmsred
Copy link
Collaborator Author

catmsred commented Feb 5, 2024

@holmanb I don't think anyone has validated the NoCloud reference example change starting from the beginning of the example, but if you're okay with merging that I'm fine with it too.

Copy link
Contributor

@s-makin s-makin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few nits. The tutorial still runs fine, so no problems there, but I did have problems getting tox - doc to run. Some sort of a problem with the pyspelling module?

dedent(
"""\
# On a machine without an ``/etc/hostname`` file, don't create it
# In most clouds, this will results in a DHCP configured hostname
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# In most clouds, this will results in a DHCP configured hostname
# In most clouds, this will result in a DHCP-configured hostname

dedent(
"""\
# On a machine without an ``/etc/hostname`` file, don't create it
# In most clouds, this will results in a DHCP configured hostname
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# In most clouds, this will results in a DHCP configured hostname
# In most clouds, this will result in a DHCP-configured hostname

cloudinit/config/cc_update_hostname.py Show resolved Hide resolved
cloudinit/config/cc_set_hostname.py Show resolved Hide resolved
catmsred and others added 4 commits February 7, 2024 08:56
If a cloud or user sets create_hostname_file to false (as GCP does)
the examples in our docs for setting the hostname will not work.
This change updates those examples to also set create_hostname_file
to true.
Co-authored-by: James Falcon <therealfalcon@gmail.com>
@TheRealFalcon TheRealFalcon merged commit cb08cab into canonical:main Feb 9, 2024
29 checks passed
blackboxsw pushed a commit that referenced this pull request Feb 15, 2024
)

If a cloud or user sets create_hostname_file to false (as GCP does)
the examples in our docs for setting the hostname will not work.
This change updates those examples to also set create_hostname_file
to true.
blackboxsw pushed a commit that referenced this pull request Feb 15, 2024
)

If a cloud or user sets create_hostname_file to false (as GCP does)
the examples in our docs for setting the hostname will not work.
This change updates those examples to also set create_hostname_file
to true.
blackboxsw pushed a commit that referenced this pull request Feb 16, 2024
)

If a cloud or user sets create_hostname_file to false (as GCP does)
the examples in our docs for setting the hostname will not work.
This change updates those examples to also set create_hostname_file
to true.
blackboxsw pushed a commit that referenced this pull request Feb 16, 2024
)

If a cloud or user sets create_hostname_file to false (as GCP does)
the examples in our docs for setting the hostname will not work.
This change updates those examples to also set create_hostname_file
to true.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants