bin_dir: handle flatcar + non root control plane - #13451
Conversation
|
Skipping CI for Draft Pull Request. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: VannTen The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
c8c72b2 to
bbc7021
Compare
|
/label tide/merge-method-merge |
|
So the molecule change we're needed, and appears to works outside the PR context, so taking those out as well which should help with reducing the review load (a bit) on #12299 |
|
Kata molecule verify breaks after merge. Its |
| # TODO handle in bin_dir when the task is delegated (should be the delegated host value) | ||
| # while respecting defaults (control node is special cased because possibly no access to /usr/*) | ||
| bin_dir: "{{ ('/usr/local/bin' if ansible_os_family != 'Flatcar' else '/opt/bin') | ||
| if inventory_hostname != 'localhost' else |
There was a problem hiding this comment.
A node literally named localhost now gets /root/.cache/kubespray for kubelet etc.
There was a problem hiding this comment.
I think localhost can only be the ansible controller ?
Maybe instead I could use ansible_user_id == 'root' or ansible_user_id == ansible_become_user ... Wdty ?
There was a problem hiding this comment.
I think localhost can only be the ansible controller ?
Yes, but in a all in one setup(localhost ansible_connection=local) localhost is also a node.
Maybe instead I could use
ansible_user_id == 'root'oransible_user_id == ansible_become_user... Wdty ?
ansible_user_id == 'root' works for me.
There was a problem hiding this comment.
I'll go with the ansible_user_id since it seems more aligned with the semantics.
(But does kubespray actually work to deploy a single node cluster on the controller ? I don't think we test that 🤔 )
There was a problem hiding this comment.
I'll go with the ansible_user_id since it seems more aligned with the semantics.
The gather needs user as well as distribution.
| - name: Get OS facts (needed for bin_dir resolution) | ||
| setup: | ||
| gather_subset: | ||
| - '!all,!min' |
There was a problem hiding this comment.
gather_subset: ['!all,!min', 'distribution'] doesn't split, ansible just gathers min. Use the string form '!all,!min,distribution'.
There was a problem hiding this comment.
does ['!all', '!min', 'distribution'] works then ? Makes diffs more explicit
|
/label ci-extended |
Actually, this is currently subtly broken because kubectl (and hence bin_dir) use the value of the original host, not of the delegated to host. I didn't handle it but I should have thought of that. Fixing that + adding a control_plane[0] only facts collection in remove should negate the need for facts collection on removed but non-reset node. |
764442b to
519f4a5
Compare
Agreed, that's the right fix. One thing to cover while you're in there: |
|
I have for now: # resolve variables across delegation
#
# this should point to the correct bin_dir in all contexts,
# but when not using delegation, prefers the usual bin_dir
_delegated_vars: "{{ hostvars[ansible_delegated_vars.keys()[0]] }}"
delegated_bin_dir: "{{
_delegated_vars['bin_dir'] |
default(('/usr/local/bin'
if _delegated_vars['ansible_facts']['os_family'] != 'Flatcar'
else '/opt/bin')
if _delegated_vars['ansible_facts']['user_id'] == (_delegated_vars['ansible_become_user'] | d('root'))
else _delegated_vars['ansible_facts']['env'].HOME + '/.local/bin'
)
if ansible_delegated_vars is defined
else
bin_dir
}}"This seems to work, but well... It ain't pretty, to say the least |
- Handle the Flatcar specific bin_dir directly in the default definition of Flatcar instead of having special cases in bootstrap_os and tests/common_vars - Non-root handling is mostly for the Ansible controller, which might run as non-root and without sudo privileges. It's doubtful it works for anything else.
The molecule_run.sh isn't really needed since the switch to gitlab-ci matrix runs. Also use the inventory variables pattern for kata-containers.
519f4a5 to
cf4a322
Compare
|
Ouch. Apparently the _var_ns stuff does not work before ansible-core 2.19 and the templating rewrite, vars is fully evaluated on templating :/ |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
Make bin_dir defaults handle
(this was taken from #12937 and the rootless stuff specifically comes from here, since localhost becomes more important for download in that PR).
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
The default for bin_dir on control node is up to discussion
Does this PR introduce a user-facing change?: