-
Notifications
You must be signed in to change notification settings - Fork 1
Add Docker-based Tofu and Ansible operations #12
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
base: main
Are you sure you want to change the base?
Conversation
- Add tofu.groovy: Functions for backend init, workspace management, apply/destroy - Add ansible.groovy: Functions for running playbooks and managing inventory - Add infrastructure.groovy: Helper functions for config, SSH keys, and workspace naming
- Update tofu.groovy to execute all commands in Docker - Update ansible.groovy runPlaybook to use Docker - Pass AWS credentials as environment variables to container - Mount workspace and SSH keys into container - Fixes 'tofu: not found' error on Jenkins agents
- Remove invalid steps.env access that caused MissingPropertyException - AWS credentials now inherited from withCredentials block via -e flags - Docker run automatically picks up AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY from environment - Fixes 'No such property: env for class: org.jenkinsci.plugins.workflow.cps.DSL' error
slickwarren
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not very well versed in this but I don't see anything standing out as an issue. Would like the main contributor's review just in case we miss something.
| } | ||
|
|
||
| // Run the init-backend.sh script which generates backend.tf and runs tofu init | ||
| def initCommand = "cd ${config.dir} && ./scripts/init-backend.sh ${scriptArgs.join(' ')}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not a fan of this being hard-coded, do we do this anywhere else in the shared lib?
what about something like this instead?
qa-jenkins-library/vars/container.groovy
Lines 73 to 82 in 61a5552
| if (params?.configureScript) { | |
| // by doing this we accept all build and configure going to run from dir, 'docker build .', currently target is in validation dir so this is necessary | |
| def statusConfigure = steps.sh(script: "./${params.dir}/${params?.configureScript}", returnStatus: true) | |
| if (statusConfigure != 0) { | |
| error "Build script failed with ${statusBuild}" | |
| } | |
| } | |
| def statusBuild = steps.sh(script: "./${params.dir}/${params.buildScript}", returnStatus: true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not seeing the problem as it's only designed to run the init-backend script.
Introduce shared library functions for Tofu and Ansible operations, enabling execution within Docker containers. Enhance AWS credentials handling and SSH key management for improved security and functionality. Implement infrastructure helpers for configuration management and workspace handling.