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

Implemented the before_bootstrap method to provide a static IP addres… #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vondrt4
Copy link

@vondrt4 vondrt4 commented Oct 25, 2019

Without this, the knife bootstrap method has no clue where the newly bootstrapped server is.
It would be much nicer to actually read the value from oVirt, but my use case is fixed IP addresses, so I'm happy.
There is more work that needs to be done to make this gem up to date with Chef 15. But my other changes were to knife-cloud 1.2.3: /lib/chef/knife/cloud/chefbootstrap
reverting attribute changes from https://github.com/chef/knife-cloud/pull/117/files

and chef 15.2.20: /lib/chef/knife/bootstrap.rb
+require "chef/knife/bootstrap/train_connector" +require "chef/knife/bootstrap/chef_vault_handler"
and the bootstrap template:
missing "channel" attribute changed to "stable" by hand

Copy link

@dmlb2000 dmlb2000 left a comment

Choose a reason for hiding this comment

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

Other than the SSL certificate validation, the code looks good to me. I've not done testing yet though.

lib/chef/knife/cloud/ovirt_service.rb Outdated Show resolved Hide resolved
@karcaw
Copy link
Member

karcaw commented Oct 28, 2019

@vondrt4 i'm a little confused as to why we need to set the bootstrap_ip_address deep in the code. It is a knife config value already. We just use the variable that is already set to pass to the cloud-init parameters so that cloud-init sets up the IP address on the machine so that the bootstrap can login. I dont have a complete config in the README it seems, so its hard to see how that gets set. In your example it would look like this:

knife[:bootstrap_ip_address]='192.168.0.241'
knife[:ovirt_cloud_init] = {
 ssh_authorized_keys: [File.read("#{ENV['HOME']}/.ssh/id_rsa.pub")],
 ip: knife[:bootstrap_ip_address],
 netmask: '255.255.255.0',
 gateway: '192.168.250.1',
 nicname: 'ens3',
 dns: '192.168.250.200',
 domain: 'example.com',
 hostname: knife[:chef_node_name],
#  custom_script: File.read("#{ENV['HOME']}/.chef/cloud-init-ubuntu.yaml")
}.to_yaml

@vondrt4
Copy link
Author

vondrt4 commented Oct 29, 2019

@dmlb2000 I have amended the pull request. The off-topic part with forcing the tool to not validate certificates has been removed. I know barely enough about the code to make it a config file entry. I don't feel braave enough to make it a command-line switch.

@karcaw Believe me, I have tried to do that first according to the original README. It does not work with knife from Chef 15. It ends with errors showing that the bootstrap code does not know the address to bootstrap. If you set it in the config file like that, it probably gets re-initialized to nil somewhere.

Please have a look at the README of knife-cloud. The writer of a cloud driver is supposed launch an instance and then query the cloud for its address and set :bootstrap_ip_address in the before_bootstrap method. It would be possible to do if the image has ovirt_guest_agent in it. My solution is only a hack to keep the driver working at the same quality it had before. But there is still work to do to get up to date with the knife_cloud project.

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.

3 participants