Skip to content

Commit

Permalink
Adding custom imports on Ansible
Browse files Browse the repository at this point in the history
Change-Id: I7b2575d4252f040162ac94518bb3844a9b6fd54c
  • Loading branch information
rambleraptor authored and nelsonjr committed Feb 16, 2018
1 parent e985d5a commit 1a53c43
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions products/dns/ansible.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ objects: !ruby/object:Api::Resource::HashArray
skip: true
ResourceRecordSet:
version_added: '2.6'
imports:
- copy
- datetime
- time
create: |
change = create_change(None, updated_record(module), module)
change_id = int(change['id'])
Expand Down
3 changes: 0 additions & 3 deletions products/dns/helpers/ansible_provider_resource_set.py.erb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ def update_soa(module):
original_soa = prefetch_soa_resource(module)

# Create a clone of the SOA record so we can update it
import copy
updated_soa = copy.deepcopy(original_soa)

soa_parts = updated_soa['rrdatas'][0].split(' ')
Expand Down Expand Up @@ -112,7 +111,6 @@ def wait_for_change_to_complete(change_id, module):
while status == 'pending':
status = get_change_status(change_id, module)
if status != 'done':
import time
time.sleep(0.5)


Expand All @@ -123,7 +121,6 @@ def get_change_status(change_id, module):


def new_change_request():
import datetime
return {
'kind': 'dns#change',
'additions': [],
Expand Down
5 changes: 5 additions & 0 deletions templates/ansible/resource.erb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ RETURN = '''

from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequestException
import json
<% if config['imports'] && !config['imports'].empty? -%>
<% config['imports'].each do |import| -%>
<%= lines("import #{import}") -%>
<% end # config['imports'].each -%>
<% end # config['imports'] -%>

################################################################################
# Main
Expand Down

0 comments on commit 1a53c43

Please sign in to comment.