Use kubectl apply instead of create/replace (#1610)
Disable checks for existing resources to speed up execution.pull/1624/head
parent
85c237bc1d
commit
4c88ac69f2
|
@ -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)
|
||||
|
||||
else:
|
||||
module.fail_json(msg='Unrecognized state %s.' % state)
|
||||
|
|
Loading…
Reference in New Issue