Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ansible facts modules #247

Merged

Conversation

rambleraptor
Copy link
Contributor

This may end up being a long-running PR.

This PR is meant to get support for Ansible facts modules started. So far, the gcp_compute_instance_facts module works.

There is missing documentation and I doubt linters will work on this.

Let me know your thoughts on the best way to slowly merge this in.


[all]

[terraform]

[puppet]

[puppet-compute]

[puppet-sql]

[puppet-storage]

[chef]

[chef-compute]

[chef-sql]

[chef-storage]

[ansible]

@modular-magician
Copy link
Collaborator

modular-magician commented Jun 5, 2018

I am a robot that works on MagicModules PRs!

I built this PR into one or more PRs on other repositories, and when those are closed, this PR will also be merged and closed.

@rambleraptor
Copy link
Contributor Author

This is currently generating the gcp_compute_instance_facts module and uses the gcp_compute_instance integration test for a full end-to-end test of both modules.

@rambleraptor rambleraptor changed the title WIP: Ansible facts modules Ansible facts modules Jul 10, 2018
@rambleraptor
Copy link
Contributor Author

rambleraptor commented Jul 10, 2018

Facts modules are in a good place now! I'm successfully building out 1 facts module (gcp_compute_instance_facts) that successfully passes Ansible's linters. That facts module is used as the verifying data source for gcp_compute_instance's integration test successfully.

What comes next (but not necessarily in this PR)?

  • Fixing up the Example class so that I can build facts examples from regular examples.
  • More facts modules! If I can build facts examples from regular examples, there should be no configuration that needs to happen.
  • I'm pretty convinced I could combine this into the Ansible provider, so that'll probably happen very soon.

@danawillow
Copy link
Contributor

Exciting! Are you still looking for a code review for this or do you have more stuff you're hoping to get done in this PR before I take a look?

@rambleraptor
Copy link
Contributor Author

rambleraptor commented Jul 10, 2018 via email

@modular-magician
Copy link
Collaborator

I am a robot that works on MagicModules PRs!
I checked the downstream repositories (see README.md for which ones I can write to), and none of them seem to have any changes.

Once this PR is approved, you can feel free to merge it without taking any further steps.

Copy link
Contributor

@danawillow danawillow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks reasonable to me, but I'd like to see it get generated- looks like the magician didn't think there was anything to generate.

compile:
tests: !ruby/object:Api::Resource::HashArray
# This would be for custom network responses. Tests work by running some block
# of autogenerated Chef/Puppet code and then verifying the network calls.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment can probably be changed, since this file is clearly for ansible only

# Holds all information necessary to run a facts module and verify the
# creation / deletion of a resource.
#
# command - The gcloud command being run
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this documentation lines up with this class

author: Google Inc. (@googlecloudplatform)
overrides: !ruby/object:Provider::ResourceOverrides
Instance: !ruby/object:Provider::Ansible::ResourceOverride
generate_facts: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, every resource that's listed in this file is going to have generate_facts: true, right? Is there a way we can avoid having to explicitly say that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just wanted to do that temporarily. My intention is to set that to true by default (and probably merge this provider into the regular Ansible provider).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems very much like enabled: true, right?

Google::StringUtils.underscore(object.name),
'facts'].join('_')
[
"- name: verify that #{obj_name} was #{verb}",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a lot of formatting things in here- would it make sense for this part to be an erb template? Or is there enough regular ruby going on that this is better?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the moment, I think it's alright to keep this as Ruby. I'm going to do a small refactor of this code in a separate PR. It should clean it up and make generating facts examples from regular examples possible.

Copy link
Contributor Author

@rambleraptor rambleraptor Jul 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As part of #343, I ended up using ERB templates. Thanks for the idea!

#343 should also enable me to build the facts examples from the regular examples, which would be super awesome and allow facts modules to be generated with no additional configuration (yay!)

@modular-magician
Copy link
Collaborator

I am a robot that works on MagicModules PRs!
I checked the downstream repositories (see README.md for which ones I can write to), and none of them seem to have any changes.

Once this PR is approved, you can feel free to merge it without taking any further steps.

@nat-henderson
Copy link
Contributor

Ooh, hey, you've got a Magician bug / Concourse bug - you pushed a commit which didn't modify the SHA of the output magic module repo, while the other one was still running. Nice! It means that Concourse never marked any of your commits as having been successfully run. I can fix it!

@nat-henderson
Copy link
Contributor

Fix is in #342. Take a look when you get a chance!

@modular-magician
Copy link
Collaborator

I am a robot that works on MagicModules PRs!

I built this PR into one or more PRs on other repositories, and when those are closed, this PR will also be merged and closed.
depends: modular-magician/ansible#53

Copy link
Contributor

@nat-henderson nat-henderson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Facts are a lot like terraform datasources, right?

author: Google Inc. (@googlecloudplatform)
overrides: !ruby/object:Provider::ResourceOverrides
Instance: !ruby/object:Provider::Ansible::ResourceOverride
generate_facts: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems very much like enabled: true, right?

@rambleraptor
Copy link
Contributor Author

rambleraptor commented Jul 15, 2018 via email

@nat-henderson
Copy link
Contributor

Yeah... I see what you're saying, but I'm feeling suspicious of adding a new provider which will merge code into the same downstream repo. If we don't have a good reason right now to split it out, I vote we don't split it out - it'll never be easier to combine than it is today.

@rambleraptor
Copy link
Contributor Author

rambleraptor commented Jul 16, 2018 via email

@modular-magician
Copy link
Collaborator

I am (still) a robot that works on MagicModules PRs!

I just wanted to let you know that your changes (as of commit aa22694) have been included in your existing downstream PRs.

@modular-magician
Copy link
Collaborator

I am (still) a robot that works on MagicModules PRs!

I just wanted to let you know that your changes (as of commit a1863bb) have been included in your existing downstream PRs.

@modular-magician
Copy link
Collaborator

I am (still) a robot that works on MagicModules PRs!

I just wanted to let you know that your changes (as of commit 8610537) have been included in your existing downstream PRs.

@modular-magician
Copy link
Collaborator

I am (still) a robot that works on MagicModules PRs!

I just wanted to let you know that your changes (as of commit df2393e) have been included in your existing downstream PRs.

Tracked submodules are build/puppet/compute build/puppet/sql build/puppet/storage build/puppet/container build/puppet/dns build/puppet/pubsub build/puppet/resourcemanager build/chef/compute build/chef/sql build/chef/storage build/chef/container build/chef/dns build/terraform build/ansible.
@modular-magician modular-magician merged commit abc39f9 into GoogleCloudPlatform:master Jul 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants