GithubHelp home page GithubHelp logo

ilijamt / terraform-provider-awx Goto Github PK

View Code? Open in Web Editor NEW
6.0 4.0 0.0 2.08 MB

A complete terraform provider for AWX

License: MIT License

Makefile 0.10% Go 96.43% Smarty 3.34% JavaScript 0.13%
awx golang provider terraform

terraform-provider-awx's Introduction

AWX Terraform Provider

Go Report Card Codecov GitHub go.mod Go version (subdirectory of monorepo) GitHub Release

An autogenerated terraform provider based on the API specifications as provided by the /api/v2/ endpoint.

AWX Versions

Currently, built provider versions for AWX. To see which ones are active check versions.yaml

  • 23.5.1
  • 23.6.0
  • 23.7.0
  • 23.8.1
  • 23.9.0
  • 24.0.0
  • 24.1.0
  • 24.2.0

TODO:

  • Unit tests
  • Integration tests

Download a new version of the API

You need to spin up a version of AWX you want to download the API spec from. Older version of AWX report incorrect API spec. So manual changes may be required to fix them.

export AWX_VERSION=24.2.0
mkdir -p resources/api/$AWX_VERSION/config resources/api/$AWX_VERSION/gen-data
cat <<EOF > resources/api/$AWX_VERSION/config/default.json
{
  "api_version": "$AWX_VERSION"
}
EOF
make generate-config VERSION=$AWX_VERSION
make download-api VERSION=$AWX_VERSION
make generate-config VERSION=$AWX_VERSION

Check the previous version of the APIs inside the config/types folder to see about customization.

Build the version of the current API

make generate

If you want to build an API for the 23.7.0 version just run

make generate VERSION=23.7.0

Setup AWX for local testing

Make sure you checkout the AWX project locally, and have basic requirements setup, like docker, docker-compose, python, ansible, ansible-builder.

export AWX_VERSION=24.1.0
git checkout $AWX_VERSION
make clean
make ui-devel
make docker-compose-build
make docker-compose

terraform-provider-awx's People

Contributors

dependabot[bot] avatar ilijamt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

terraform-provider-awx's Issues

awx_project status mutates

The status property mutates when AWX runs an update, which causes an error between the state and the response from the API

 Error: Provider produced inconsistent result after apply
 
 When applying changes to
 module.awx_project["mihai-sandbox"].awx_project.target, provider
 "provider[\"registry.terraform.io/ilijamt/awx\"]" produced an unexpected
 new value: .status: was cty.StringVal("successful"), but now
 cty.StringVal("pending").

Error when there are no extra vars defined in inventory source

If the extra_vars is empty you get an error that the state has changed with a new value

│ When applying changes to
│ module.awx_inventory["inv.development"].awx_inventory_source.inventory,
│ provider "provider[\"registry.terraform.io/ilijamt/awx\"]" produced an
│ unexpected new value: .source_vars: was cty.StringVal(""), but now
│ cty.StringVal("---").
│ 
│ This is a bug in the provider, which should be reported in the provider's
│ own issue tracker.

Bug when applying with inconsistent result

Hi,

When applying my plan, I get the following changes (the value of variables changed because I edited the inventory using the interface):

 # awx_inventory.this will be updated in-place
  ~ resource "awx_inventory" "this" {
      + host_filter                     = (known after apply)
        id                              = 187
        name                            = "Inventory"
      - variables                       = "---" -> null
        # (10 unchanged attributes hidden)
    }

And after aply, I obtain the following error:

│ Error: Provider produced inconsistent result after apply
│ 
│ When applying changes to awx_inventory.this, provider "provider[\"registry.opentofu.org/ilijamt/awx\"]" produced an unexpected new value:
│ .variables: was cty.StringVal(""), but now cty.StringVal("---").
│ 
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.

I don't know if this is relevant, but I'm using the latest version and OpenTofu to apply the plan.
Let me know if you need more information.

Support multiple version of AWX

The goal is to be able to support multiple version of the AWX API with the terraform provider.
Or at least the last X versions.

For now, let's create a structure that would support at least the following API versions:

21.8.0
21.9.0
21.10.0

How to do the SemVer tagging:

  • vX.Y.Z-2180
  • v21.8.X (we follow the API version and everything else is a patch, as changes in the api are possible in between minor versions as well)
  • vX.Y.Z-api2180

Associate Job Template to Workflow

Hello,

I see you have awx_job_template and awx_workflow_job_template resources but no way to associate a job template to a workflow? Am I missing something?

Thanks,
Paul

Help with extra_vars format in awx_job_template

Hi, I want to add extra_vars to a job template, but says it's a string but I don two how to formate the extra_vars variable.

Here is the code I tested:

resource "awx_job_template" "uptime-kuma-notification-add" {
  name               = "uptime-kuma-notification-add"
  inventory          = awx_inventory.uptime-kuma.id
  verbosity          = 0
  job_type           = "run"
  playbook           = "playbooks/config.yml"
  extra_vars         = jsonencode({
    "role_action": "notification-add"
  })
  project            = awx_project.uptime-kuma.id
  scm_branch         = ""
  job_slice_count    = 2
  allow_simultaneous = true
}

And here is the error:

│ Error: Unable to create resource for JobTemplate on /api/v2/job_templates/
│ 
│   with awx_job_template.uptime-kuma-notification-add,
│   on project-uptime-kuma.tf line 25, in resource "awx_job_template" "uptime-kuma-notification-add":
│   25: resource "awx_job_template" "uptime-kuma-notification-add" {
│ 
│ invalid status code: 400, on /api/v2/job_templates/ with {"extra_vars":["Not
│ a valid string."]}

Any help? Thanks!

awx_job_template_associate_credential import failed

I was trying to import my manually created templates credentials and getting below error. can you please guide me here

import {
to = awx_job_template_associate_credential.fetch_sdts
id = 18
}

│ Error: Unable to import state for JobTemplate association, invalid format.

│ requires the identifier to be set to <job_template_id>/<credential_id>, currently set to 18

sametime i could successfully import templates using below import

import {
to = awx_job_template.fetch_sdts
id = 18
}

Support to authenticate with user token

Hi @ilijamt,

Congrats for the excellent work!

I'm using your provider to manage our Tower/AWX instance, and it will be nice to allow authenticating using only a user token to avoid using credentials from the user and make it easier to rotate tokens.
Do you think it might make sense to add this feature?

Optional fields are considered manadatory

it appears the optional fields are mandatory there is no flexibility to control the behaviour. i have requirement on few items like to have execution environment golobally available along with that few creentials but while testing it appears for creating credential organization has been made mandatory but as per documentation it says optional. Similar problems observed with settings all are listed as optional but have to fill everthing there is no flexibility on these items.

https://registry.terraform.io/providers/ilijamt/awx/latest/docs/resources/credential
https://registry.terraform.io/providers/ilijamt/awx/latest/docs/resources/settings_auth_saml

image

Feature: Instance groups association with teams

I would like to see if we could implement roles to team of type instance groups. I didnt find any documenation or any such examples that could point if this is already been developed, but as far as i check it seems we dont have it implemented yet. Would it be possible to get this included in the stack?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.