-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Add check that kube-master, kube-node and etcd groups are not empty. #3367
Conversation
Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA. It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
Please commit with github user and if so, sign the cla. |
Done. |
@@ -5,6 +5,15 @@ | |||
- ansible_version.full|version_compare('2.3.0', '>=') | |||
run_once: yes | |||
|
|||
- name: Stop if either kube-master, kube-node or etcd is empty |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this create any issues when you run playbooks like upgrade / scale and you limit to either masters, nodes or etcd's ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. I didn't think of it.
I'll check...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works like a charm. ansible is clever enough to keep groups and other settings intact while using --limit. If to thing carefully it should behave this way because while limiting to some hosts you may still need group and host vars from others. Or you may need to delegate a task to another host. So ansible can't touch your inventory.
2018-09-20 16:52:08 mgserjio: tmp$ cat i.ini
[kube-master]
master1 ansible_host=127.0.0.1
[etcd]
etcd1 ansible_host=127.0.0.1
[kube-node]
node1 ansible_host=127.0.0.1
node2 ansible_host=127.0.0.1
node3 ansible_host=127.0.0.1
node4 ansible_host=127.0.0.1
node5 ansible_host=127.0.0.1
[k8s-cluster:children]
kube-master
kube-node
2018-09-20 16:52:21 mgserjio: tmp$ cat task.yml
- hosts: k8s-cluster
connection: local
tasks:
- name: Stop if either kube-master, kube-node, etcd is empty
assert:
that: groups.get('{{ item }}')
with_items:
- kube-master
- kube-node
- etcd
- hosts: kube-node
connection: local
tasks:
- name: Stop if either kube-master, kube-node, etcd is empty
assert:
that: groups.get('{{ item }}')
with_items:
- kube-master
- kube-node
- etcd
2018-09-20 16:52:27 mgserjio: tmp$ ansible-playbook -i i.ini task.yml --limit master1
PLAY [k8s-cluster] **********************************************************************************************************************************************************************
TASK [Gathering Facts] ******************************************************************************************************************************************************************
ok: [master1]
TASK [Stop if either kube-master, kube-node, etcd is empty] *****************************************************************************************************************************
ok: [master1] => (item=kube-master) => {
"changed": false,
"item": "kube-master",
"msg": "All assertions passed"
}
ok: [master1] => (item=kube-node) => {
"changed": false,
"item": "kube-node",
"msg": "All assertions passed"
}
ok: [master1] => (item=etcd) => {
"changed": false,
"item": "etcd",
"msg": "All assertions passed"
}
PLAY [kube-node] ************************************************************************************************************************************************************************
skipping: no hosts matched
PLAY RECAP ******************************************************************************************************************************************************************************
master1 : ok=2 changed=0 unreachable=0 failed=0
Would it be better to move some checks to earlier stages and perform on localhost? |
PTAL |
ci check this |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Atoms The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
This can save a lot of time debugging silly mistakes.