Browse Source

Use kubectl apply instead of create/replace (#1610)

Disable checks for existing resources to speed up execution.
pull/1624/head
Matthew Mosesohn 7 years ago
committed by GitHub
parent
commit
4c88ac69f2
1 changed files with 4 additions and 11 deletions
  1. 15
      library/kube.py

15
library/kube.py

@ -139,7 +139,7 @@ class KubeManager(object):
if check and self.exists():
return []
cmd = ['create']
cmd = ['apply']
if not self.filename:
self.module.fail_json(msg='filename required to create')
@ -150,10 +150,7 @@ class KubeManager(object):
def replace(self):
if not self.force and not self.exists():
return []
cmd = ['replace']
cmd = ['apply']
if self.force:
cmd.append('--force')
@ -271,7 +268,7 @@ def main():
manager = KubeManager(module)
state = module.params.get('state')
if state == 'present':
result = manager.create()
result = manager.create(check=False)
elif state == 'absent':
result = manager.delete()
@ -283,11 +280,7 @@ def main():
result = manager.stop()
elif state == 'latest':
if manager.exists():
manager.force = True
result = manager.replace()
else:
result = manager.create(check=False)
result = manager.replace()
else:
module.fail_json(msg='Unrecognized state %s.' % state)

Loading…
Cancel
Save