Skip to content

Commit

Permalink
Ansible - RuntimeConfig Variables (#2521)
Browse files Browse the repository at this point in the history
Merged PR #2521.
  • Loading branch information
rambleraptor authored and modular-magician committed Oct 23, 2019
1 parent cf81a3d commit bcc9801
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build/ansible
8 changes: 6 additions & 2 deletions products/runtimeconfig/ansible.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@ datasources: !ruby/object:Overrides::ResourceOverrides
facts: !ruby/object:Provider::Ansible::FactsOverride
has_filters: false
Variable: !ruby/object:Overrides::Ansible::ResourceOverride
exclude: true
facts: !ruby/object:Provider::Ansible::FactsOverride
has_filters: false
overrides: !ruby/object:Overrides::ResourceOverrides
Variable: !ruby/object:Overrides::Ansible::ResourceOverride
exclude: true
provider_helpers:
- 'products/runtimeconfig/helpers/ansible/variable_delete_config.py'
transport: !ruby/object:Overrides::Ansible::Transport
encoder: encode_request
files: !ruby/object:Provider::Config::Files
resource:
<%= lines(indent(compile('provider/ansible/resource~compile.yaml'), 4)) -%>
12 changes: 12 additions & 0 deletions products/runtimeconfig/ansible_version_added.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,22 @@
:facts:
:Config:
:version_added: '2.10'
:Variable:
:version_added: '2.10'
:regular:
:Config:
:version_added: '2.10'
:description:
:version_added: '2.10'
:name:
:version_added: '2.10'
:Variable:
:version_added: '2.10'
:value:
:version_added: '2.10'
:text:
:version_added: '2.10'
:name:
:version_added: '2.10'
:config:
:version_added: '2.10'
1 change: 1 addition & 0 deletions products/runtimeconfig/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ objects:
The name of the variable resource.
required: true
input: true
pattern: projects/{{project}}/configs/{{config}}/variables/{{name}}
- !ruby/object:Api::Type::String
name: 'config'
description: |
Expand Down
32 changes: 32 additions & 0 deletions products/runtimeconfig/examples/ansible/variable.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2017 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
--- !ruby/object:Provider::Ansible::Example
task: !ruby/object:Provider::Ansible::Task
name: gcp_runtimeconfig_variable
code:
name: prod-variables/hostname
config: 'my-config'
text: example.com
project: <%= ctx[:project] %>
auth_kind: <%= ctx[:auth_kind] %>
service_account_file: <%= ctx[:service_account_file] %>
dependencies:
- !ruby/object:Provider::Ansible::Task
name: gcp_runtimeconfig_config
code:
name: 'my-config'
description: 'My config'
project: <%= ctx[:project] %>
auth_kind: <%= ctx[:auth_kind] %>
service_account_file: <%= ctx[:service_account_file] %>
register: config
19 changes: 19 additions & 0 deletions products/runtimeconfig/helpers/ansible/variable_delete_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2017 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# `config` is a useful parameter for declarative syntax, but
# is not a part of the GCP API
def encode_request(request, module):
if 'config' in request:
del request['config']
return request

0 comments on commit bcc9801

Please sign in to comment.