Use kubectl apply instead of create/replace (#1610)
Disable checks for existing resources to speed up execution.
This commit is contained in:
parent
85c237bc1d
commit
4c88ac69f2
1 changed files with 4 additions and 11 deletions
|
@ -139,7 +139,7 @@ class KubeManager(object):
|
||||||
if check and self.exists():
|
if check and self.exists():
|
||||||
return []
|
return []
|
||||||
|
|
||||||
cmd = ['create']
|
cmd = ['apply']
|
||||||
|
|
||||||
if not self.filename:
|
if not self.filename:
|
||||||
self.module.fail_json(msg='filename required to create')
|
self.module.fail_json(msg='filename required to create')
|
||||||
|
@ -150,10 +150,7 @@ class KubeManager(object):
|
||||||
|
|
||||||
def replace(self):
|
def replace(self):
|
||||||
|
|
||||||
if not self.force and not self.exists():
|
cmd = ['apply']
|
||||||
return []
|
|
||||||
|
|
||||||
cmd = ['replace']
|
|
||||||
|
|
||||||
if self.force:
|
if self.force:
|
||||||
cmd.append('--force')
|
cmd.append('--force')
|
||||||
|
@ -271,7 +268,7 @@ def main():
|
||||||
manager = KubeManager(module)
|
manager = KubeManager(module)
|
||||||
state = module.params.get('state')
|
state = module.params.get('state')
|
||||||
if state == 'present':
|
if state == 'present':
|
||||||
result = manager.create()
|
result = manager.create(check=False)
|
||||||
|
|
||||||
elif state == 'absent':
|
elif state == 'absent':
|
||||||
result = manager.delete()
|
result = manager.delete()
|
||||||
|
@ -283,11 +280,7 @@ def main():
|
||||||
result = manager.stop()
|
result = manager.stop()
|
||||||
|
|
||||||
elif state == 'latest':
|
elif state == 'latest':
|
||||||
if manager.exists():
|
result = manager.replace()
|
||||||
manager.force = True
|
|
||||||
result = manager.replace()
|
|
||||||
else:
|
|
||||||
result = manager.create(check=False)
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
module.fail_json(msg='Unrecognized state %s.' % state)
|
module.fail_json(msg='Unrecognized state %s.' % state)
|
||||||
|
|
Loading…
Reference in a new issue