diff --git a/.editorconfig b/.editorconfig index 26888c9..f8d93ce 100644 --- a/.editorconfig +++ b/.editorconfig @@ -18,3 +18,6 @@ indent_size = 4 trim_trailing_whitespace = false eclint_indent_style = unset + +[{*.yaml,*.yml}] +indent_size = 2 # Set the indent size to 2 spaces diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 2b95c1d..0ae2b96 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,29 +1,29 @@ version: 2 updates: - - package-ecosystem: gomod - directory: '/' - schedule: - interval: monthly - open-pull-requests-limit: 10 - reviewers: - - sbaerlocher - assignees: - - sbaerlocher - commit-message: - prefix: fix - prefix-development: chore - include: scope + - package-ecosystem: gomod + directory: "/" + schedule: + interval: monthly + open-pull-requests-limit: 10 + reviewers: + - sbaerlocher + assignees: + - sbaerlocher + commit-message: + prefix: fix + prefix-development: chore + include: scope - - package-ecosystem: docker - directory: '/' - schedule: - interval: monthly - open-pull-requests-limit: 10 - reviewers: - - sbaerlocher - assignees: - - sbaerlocher - commit-message: - prefix: fix - prefix-development: chore - include: scope + - package-ecosystem: docker + directory: "/" + schedule: + interval: monthly + open-pull-requests-limit: 10 + reviewers: + - sbaerlocher + assignees: + - sbaerlocher + commit-message: + prefix: fix + prefix-development: chore + include: scope diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4fe60fa..96a6a28 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,19 +6,19 @@ jobs: test_go: runs-on: ubuntu-latest steps: - - name: Install Go - uses: actions/setup-go@v1 - with: - go-version: 1.18.x + - name: Install Go + uses: actions/setup-go@v1 + with: + go-version: 1.18.x - - name: Checkout code - uses: actions/checkout@v2 + - name: Checkout code + uses: actions/checkout@v2 - # - name: Test - # run: go test ./... + # - name: Test + # run: go test ./... - - name: build - run: go build -o main + - name: build + run: go build -o main test_docker: runs-on: ubuntu-latest diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e0b651..1a49dac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,59 +3,65 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) and [human-readable changelog](https://keepachangelog.com/en/1.0.0/). -## master +## [Unreleased] -## 0.0.8 +## [0.0.9] - 2023-11-11 ### Changed -- feat(variable): Add 'GalaxyForce' booleant +- **Dependabot Configuration:** Improved formatting in `.github/dependabot.yml` for enhanced readability and consistency. +- **Changelog Formatting:** Updated the changelog format in `CHANGELOG.md` for better clarity and adherence to the human-readable standard. +- **Dependency Updates:** Modified versions in `go.mod` and `go.sum` to incorporate newer dependency versions. +- **`main.go` Adjustments:** Extensive revision of flag descriptions and comments to improve user-friendliness and comprehensibility. -## 0.0.7 +## [0.0.8] - 2023-11-09 ### Changed -- fix(deps): bump arillso/ansible from 2.15.4 to 2.15.5 +- Add 'GalaxyForce' boolean variable. -## 0.0.6 +## [0.0.7] - 2023-11-02 ### Changed -- Bump go from 1.14 to 1.18 -- fix(deps): bump arillso/ansible from 2.12.4 to 2.15.4 -- fix(deps): bump github.com/arillso/go.ansible from 0.0.1 to 0.0.2 -- fix(deps): bump github.com/joho/godotenv from 1.4.0 to 1.5.1 -- fix(deps): bump github.com/urfave/cli/v2 from 2.11.1 to 2.25.7 +- Bump arillso/ansible from 2.15.4 to 2.15.5. -## 0.0.5 +## [0.0.6] - 2023-10-30 ### Changed -- Bump arillso/ansible from 2.12.0 to 2.12.4 -- Bump github.com/urfave/cli/v2 from 2.3.0 to 2.11.1 +- Bump go from 1.14 to 1.18. +- Bump arillso/ansible from 2.12.4 to 2.15.4. +- Bump github.com/arillso/go.ansible from 0.0.1 to 0.0.2. +- Bump github.com/joho/godotenv from 1.4.0 to 1.5.1. +- Bump github.com/urfave/cli/v2 from 2.11.1 to 2.25.7. -## 0.0.4 +## [0.0.5] - 2022-07-28 ### Changed -- Bump arillso/ansible from 2.10.3 to 2.12.0 -- Bump github.com/joho/godotenv from 1.3.0 to 1.4.0 -- Bump github.com/urfave/cli/v2 from 2.2.0 to 2.3.0 +- Bump github.com/urfave/cli/v2 from 2.3.0 to 2.11.1. -## 0.0.3 +## [0.0.4] - 2021-11-28 ### Changed -- Bump arillso/ansible from 2.9.7 to 2.9.9 +- Bump arillso/ansible from 2.10.3 to 2.12.0. -## 0.0.2 +## [0.0.3] - 2020-08-01 ### Changed -- Bump arillso/ansible from 2.9.6 to 2.9.7 +- Bump arillso/ansible from 2.9.7 to 2.9.9. -## 0.0.1 +## [0.0.2] - 2020-05-02 + +### Changed + +- Bump arillso/ansible from 2.9.6 to 2.9.7. + +## [0.0.1] - 2020-04-06 ### Added -- Initial Commit +- Initial Commit. diff --git a/LICENSE b/LICENSE index 5520f0e..c8b6f84 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2020 Arillso +Copyright (c) 2023 Arillso Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index b9e7688..0268a18 100644 --- a/README.md +++ b/README.md @@ -6,19 +6,83 @@ Github Action for running Ansible Playbooks. ### galaxy_file -Name of the galaxy file in your workspace. +Specifies the path to the Ansible Galaxy requirements file. -### inventory +### galaxy_force -**Required** inventory +Forces the reinstallation of roles or collections from the Galaxy file. -Name of the inventory file in your workspace. +### galaxy_api_key -### playbook +Sets the API key used for authenticating to Ansible Galaxy. + +### galaxy_api_server_url + +Defines the URL of the Ansible Galaxy API server to interact with. + +### galaxy_collections_path + +Sets the path to the directory where Galaxy collections are stored. + +### galaxy_disable_gpg_verify + +Disables GPG signature verification for Ansible Galaxy operations. + +### galaxy_force_with_deps + +Forces the installation of collections with their dependencies from Galaxy. + +### galaxy_ignore_certs + +Ignores SSL certificate validation for Ansible Galaxy requests. + +### galaxy_ignore_signature_status_codes + +Lists HTTP status codes to ignore during Galaxy signature validation. + +### galaxy_keyring + +Specifies the path to the GPG keyring used with Ansible Galaxy. + +### galaxy_offline + +Enables offline mode, preventing any requests to Ansible Galaxy. -**Required** playbook +### galaxy_pre + +Allows the installation of pre-release versions from Ansible Galaxy. + +### galaxy_required_valid_signature_count + +Sets the required number of valid GPG signatures for Galaxy content. + +### galaxy_requirements_file + +Defines the path to the Ansible Galaxy requirements file. + +### galaxy_signature + +Specifies a specific GPG signature to verify for Galaxy content. + +### galaxy_timeout + +Sets the timeout in seconds for Ansible Galaxy operations. + +### galaxy_upgrade + +Enables automatic upgrading of Galaxy collections to the latest version. + +### galaxy_no_deps + +Disables automatic resolution of dependencies in Ansible Galaxy. + +### inventory + +**Required.** Specifies one or more inventory host files for Ansible to use. + +### playbook -Name of the playbook in your workspace. +**Required.** List of playbooks to apply. ### limit @@ -38,27 +102,27 @@ Only run plays and tasks tagged with these values. ### extra_vars -Set additional variables as key=value. +Set additional variables in a key=value format for the playbook. ### module_path -Prepend paths to module library. +Prepends specified paths to the module library path list. ### check -Run a check, do not apply any changes. +Executes a dry run, showing what changes would be made without making them. ### diff -When changing (small) files and templates, show the differences in those files; works great with –check. +Shows the differences in files and templates when changing them. ### flush_cache -Clear the fact cache for every host in inventory. +Clears the fact cache for every host in the inventory. ### force_handlers -Run handlers even if a task fails. +Runs all handlers even if a task fails. ### list_hosts @@ -74,15 +138,15 @@ List all tasks that would be executed. ### syntax_check -Perform a syntax check on the playbook. +Performs a syntax check on the playbook, without executing it. ### forks -Specify number of parallel processes to use. +Defines the number of parallel processes to use during playbook execution. ### vault_id -The vault identity to use. +Specifies the identity to use when accessing an Ansible Vault. ### vault_password @@ -92,7 +156,7 @@ See [https://help.github.com/en/github/automating-your-workflow-with-github-acti ### verbose -Level of verbosity, 0 up to 4. +Sets the verbosity level, ranging from 0 (minimal output) to 4 (maximum verbosity). ### private_key @@ -102,44 +166,43 @@ See [https://help.github.com/en/github/automating-your-workflow-with-github-acti ### user -Connect as this user. +Defines the username for making connections. ### connection -Connection type to use. +Sets the type of connection to use (e.g., SSH). ### timeout -Override the connection timeout in seconds. +Overrides the default connection timeout in seconds. ### ssh_common_args -Specify common arguments to pass to sftp/scp/ssh. +Specifies common arguments to pass to all SSH-based connection methods (SSH, SCP, SFTP). ### sftp_extra_args -Specify extra arguments to pass to sftp only. +Provides extra arguments to pass only to SFTP. ### scp_extra_args -Specify extra arguments to pass to scp only. +Provides extra arguments to pass only to SCP. ### ssh_extra_args -Specify extra arguments to pass to ssh only. +Provides extra arguments to pass only to SSH. ### become -Run operations with become. +Enables privilege escalation, allowing operations to run as another user. ### become_method -Privilege escalation method to use. +Specifies the method to use for privilege escalation (e.g., sudo). ### become_user -Run operations as this user. -required: false +Sets the user to impersonate when using privilege escalation. ## Example Usage diff --git a/action.yml b/action.yml index f4e04eb..0f09c40 100644 --- a/action.yml +++ b/action.yml @@ -1,105 +1,157 @@ -name: 'Play Ansible Playbook' -description: 'Github Action for running Ansible Playbooks.' +name: "Play Ansible Playbook" +description: "Github Action for running Ansible Playbooks." inputs: galaxy_file: - description: 'Name of the galaxy file in your workspace.' + description: "Name of the galaxy file in your workspace." + required: false + + galaxy_force: + description: "Forces the reinstallation of roles or collections from the Galaxy file." + required: false + galaxy_api_key: + description: "Sets the API key used for authenticating to Ansible Galaxy." + required: false + galaxy_api_server_url: + description: "Defines the URL of the Ansible Galaxy API server to interact with." + required: false + galaxy_collections_path: + description: "Sets the path to the directory where Galaxy collections are stored." + required: false + galaxy_disable_gpg_verify: + description: "Disables GPG signature verification for Ansible Galaxy operations." + required: false + galaxy_force_with_deps: + description: "Forces the installation of collections with their dependencies from Galaxy." + required: false + galaxy_ignore_certs: + description: "Ignores SSL certificate validation for Ansible Galaxy requests." + required: false + galaxy_ignore_signature_status_codes: + description: "Lists HTTP status codes to ignore during Galaxy signature validation." + required: false + galaxy_keyring: + description: "Specifies the path to the GPG keyring used with Ansible Galaxy." + required: false + galaxy_offline: + description: "Enables offline mode, preventing any requests to Ansible Galaxy." + required: false + galaxy_pre: + description: "Allows the installation of pre-release versions from Ansible Galaxy." + required: false + galaxy_required_valid_signature_count: + description: "Sets the required number of valid GPG signatures for Galaxy content." + required: false + galaxy_requirements_file: + description: "Defines the path to the Ansible Galaxy requirements file." + required: false + galaxy_signature: + description: "Specifies a specific GPG signature to verify for Galaxy content." + required: false + galaxy_timeout: + description: "Sets the timeout in seconds for Ansible Galaxy operations." + required: false + galaxy_upgrade: + description: "Enables automatic upgrading of Galaxy collections to the latest version." + required: false + galaxy_no_deps: + description: "Disables automatic resolution of dependencies in Ansible Galaxy." required: false inventory: - description: 'Name of the inventory file in your workspace.' + description: "Specifies one or more inventory host files for Ansible to use." required: true playbook: - description: 'Name of the playbook in your workspace.' + description: "List of playbooks to apply." required: true limit: - description: 'Further limit selected hosts to an additional pattern.' + description: "Limits the playbook execution to a specific group of hosts." required: false skip_tags: - description: 'Only run plays and tasks whose tags do not match these values.' + description: "Only run plays and tasks whose tags do not match these values." required: false start_at_task: - description: 'Start the playbook at the task matching this name.' + description: "Start the playbook at the task matching this name." required: false tags: - description: 'Only run plays and tasks tagged with these values.' + description: "Executes only tasks and plays with specified tags." required: false extra_vars: - description: 'Set additional variables as key=value.' + description: "Sets additional variables in a key=value format for the playbook." required: false module_path: - description: 'Prepend paths to module library.' + description: "Prepends specified paths to the module library path list." required: false check: - description: 'Run a check, do not apply any changes.' + description: "Executes a dry run, showing what changes would be made without making them." required: false diff: - description: 'When changing (small) files and templates, show the differences in those files; works great with –check.' + description: "Shows the differences in files and templates when changing them." required: false flush_cache: - description: 'Clear the fact cache for every host in inventory.' + description: "Clears the fact cache for every host in the inventory." required: false force_handlers: - description: 'Run handlers even if a task fails.' + description: "Runs all handlers even if a task fails." required: false list_hosts: - description: 'Outputs a list of matching hosts.' + description: "Outputs a list of matching hosts." required: false list_tags: - description: 'List all available tags.' + description: "List all available tags." required: false list_tasks: - description: 'List all tasks that would be executed.' + description: "List all tasks that would be executed." required: false syntax_check: - description: 'Perform a syntax check on the playbook.' + description: "Performs a syntax check on the playbook, without executing it." required: false forks: - description: 'Specify number of parallel processes to use.' + description: "Defines the number of parallel processes to use during playbook execution." required: false vault_id: - description: 'The vault identity to use.' + description: "Specifies the identity to use when accessing an Ansible Vault." required: false vault_password: - description: 'The vault password to use.' + description: "Sets the password to use for decrypting an Ansible Vault." required: false verbose: - description: 'Level of verbosity, 0 up to 4.' + description: "Sets the verbosity level, ranging from 0 (minimal output) to 4 (maximum verbosity)." required: false private_key: - description: 'Use this key to authenticate the connection.' + description: "Specifies the SSH private key file for connections." required: false user: - description: 'Connect as this user.' + description: "Defines the username for making connections." required: false connection: - description: 'Connection type to use.' + description: "Sets the type of connection to use (e.g., SSH)." required: false timeout: - description: 'Override the connection timeout in seconds.' + description: "Overrides the default connection timeout in seconds." required: false ssh_common_args: - description: 'Specify common arguments to pass to sftp/scp/ssh.' + description: "Specifies common arguments to pass to all SSH-based connection methods (SSH, SCP, SFTP)." required: false sftp_extra_args: - description: 'Specify extra arguments to pass to sftp only.' + description: "Provides extra arguments to pass only to SFTP." required: false scp_extra_args: - description: 'Specify extra arguments to pass to scp only.' + description: "Provides extra arguments to pass only to SCP." required: false - ssh-extra-args: - description: 'Specify extra arguments to pass to ssh only.' + ssh_extra_args: + description: "Provides extra arguments to pass only to SSH." required: false become: - description: 'Run operations with become.' + description: "Enables privilege escalation, allowing operations to run as another user." required: false become_method: - description: 'Privilege escalation method to use.' + description: "Specifies the method to use for privilege escalation (e.g., sudo)." required: false become_user: - description: 'Run operations as this user.' + description: "Sets the user to impersonate when using privilege escalation." required: false runs: - using: 'docker' - image: 'Dockerfile' + using: "docker" + image: "Dockerfile" branding: - icon: 'play-circle' - color: 'black' + icon: "play-circle" + color: "black" diff --git a/go.mod b/go.mod index b5780cd..3a055b2 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/arillso/action.playbook go 1.18 require ( - github.com/arillso/go.ansible v0.0.4 + github.com/arillso/go.ansible v0.1.0 github.com/joho/godotenv v1.5.1 github.com/urfave/cli/v2 v2.25.7 ) diff --git a/go.sum b/go.sum index db21abc..a3c1067 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/arillso/go.ansible v0.0.4 h1:NG20Pohtejs7xyTJeAAmWJUXirsk67BLRYE5IvXaUBY= -github.com/arillso/go.ansible v0.0.4/go.mod h1:4xsAZCWUsdoLtOnA4BLoqd+vLD82qqqCZTxDm+c1oP8= +github.com/arillso/go.ansible v0.1.0 h1:t/u+t3y4PYcQwj/CU2QayWlDzUWZvvvaAkAv+DFxbqo= +github.com/arillso/go.ansible v0.1.0/go.mod h1:4xsAZCWUsdoLtOnA4BLoqd+vLD82qqqCZTxDm+c1oP8= github.com/cpuguy83/go-md2man/v2 v2.0.3 h1:qMCsGGgs+MAzDFyp9LpAe1Lqy/fY/qCovCm0qnXZOBM= github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= diff --git a/main.go b/main.go index f78ba43..ffdaa52 100644 --- a/main.go +++ b/main.go @@ -22,9 +22,9 @@ func main() { app := &cli.App{ Name: "Ansible Playbook Wrapper", Usage: "Executing Ansible Playbook", - Copyright: "Copyright (c) 2020 Arillso", + Copyright: "Copyright (c) 2023 Arillso", Authors: []*cli.Author{ - &cli.Author{ + { Name: "arillso", Email: "hello@arillso.io", }, @@ -33,170 +33,266 @@ func main() { Flags: []cli.Flag{ &cli.StringFlag{ Name: "galaxy-file", - Usage: "path to galaxy requirements", + Usage: "Specifies the path to the Ansible Galaxy requirements file.", EnvVars: []string{"ANSIBLE_GALAXY_FILE", "INPUT_GALAXY_FILE", "PLUGIN_GALAXY_FILE"}, }, - &cli.StringFlag{ + &cli.BoolFlag{ Name: "galaxy-force", - Usage: "galaxy force", + Usage: "Forces the reinstallation of roles or collections from the Galaxy file.", EnvVars: []string{"ANSIBLE_GALAXY_FORCE", "INPUT_GALAXY_FORCE", "PLUGIN_GALAXY_FORCE"}, }, + &cli.StringFlag{ + Name: "galaxy-api-key", + Usage: "Sets the API key used for authenticating to Ansible Galaxy.", + EnvVars: []string{"ANSIBLE_GALAXY_API_KEY"}, + }, + &cli.StringFlag{ + Name: "galaxy-api-server-url", + Usage: "Defines the URL of the Ansible Galaxy API server to interact with.", + EnvVars: []string{"ANSIBLE_GALAXY_API_SERVER_URL"}, + }, + &cli.StringFlag{ + Name: "galaxy-collections-path", + Usage: "Sets the path to the directory where Galaxy collections are stored.", + EnvVars: []string{"ANSIBLE_GALAXY_COLLECTIONS_PATH"}, + }, + &cli.BoolFlag{ + Name: "galaxy-disable-gpg-verify", + Usage: "Disables GPG signature verification for Ansible Galaxy operations.", + EnvVars: []string{"ANSIBLE_GALAXY_DISABLE_GPG_VERIFY"}, + }, + &cli.BoolFlag{ + Name: "galaxy-force-with-deps", + Usage: "Forces the installation of collections with their dependencies from Galaxy.", + EnvVars: []string{"ANSIBLE_GALAXY_FORCE_WITH_DEPS"}, + }, + &cli.BoolFlag{ + Name: "galaxy-ignore-certs", + Usage: "Ignores SSL certificate validation for Ansible Galaxy requests.", + EnvVars: []string{"ANSIBLE_GALAXY_IGNORE_CERTS"}, + }, &cli.StringSliceFlag{ - Name: "inventory,i", - Usage: "specify inventory host path", + Name: "galaxy-ignore-signature-status-codes", + Usage: "Lists HTTP status codes to ignore during Galaxy signature validation.", + EnvVars: []string{"ANSIBLE_GALAXY_IGNORE_SIGNATURE_STATUS_CODES"}, + }, + &cli.StringFlag{ + Name: "galaxy-keyring", + Usage: "Specifies the path to the GPG keyring used with Ansible Galaxy.", + EnvVars: []string{"ANSIBLE_GALAXY_KEYRING"}, + }, + &cli.BoolFlag{ + Name: "galaxy-offline", + Usage: "Enables offline mode, preventing any requests to Ansible Galaxy.", + EnvVars: []string{"ANSIBLE_GALAXY_OFFLINE"}, + }, + &cli.BoolFlag{ + Name: "galaxy-pre", + Usage: "Allows the installation of pre-release versions from Ansible Galaxy.", + EnvVars: []string{"ANSIBLE_GALAXY_PRE"}, + }, + &cli.IntFlag{ + Name: "galaxy-required-valid-signature-count", + Usage: "Sets the required number of valid GPG signatures for Galaxy content.", + EnvVars: []string{"ANSIBLE_GALAXY_REQUIRED_VALID_SIGNATURE_COUNT"}, + }, + &cli.StringFlag{ + Name: "galaxy-requirements-file", + Usage: "Defines the path to the Ansible Galaxy requirements file.", + EnvVars: []string{"ANSIBLE_GALAXY_REQUIREMENTS_FILE"}, + }, + &cli.StringFlag{ + Name: "galaxy-signature", + Usage: "Specifies a specific GPG signature to verify for Galaxy content.", + EnvVars: []string{"ANSIBLE_GALAXY_SIGNATURE"}, + }, + &cli.IntFlag{ + Name: "galaxy-timeout", + Usage: "Sets the timeout in seconds for Ansible Galaxy operations.", + EnvVars: []string{"ANSIBLE_GALAXY_TIMEOUT"}, + }, + &cli.BoolFlag{ + Name: "galaxy-upgrade", + Usage: "Enables automatic upgrading of Galaxy collections to the latest version.", + EnvVars: []string{"ANSIBLE_GALAXY_UPGRADE"}, + }, + &cli.BoolFlag{ + Name: "galaxy-no-deps", + Usage: "Disables automatic resolution of dependencies in Ansible Galaxy.", + EnvVars: []string{"ANSIBLE_GALAXY_NO_DEPS"}, + }, + &cli.StringSliceFlag{ + Name: "inventory", + Aliases: []string{"i"}, + Usage: "Specifies one or more inventory host files for Ansible to use.", EnvVars: []string{"ANSIBLE_INVENTORY", "INPUT_INVENTORY", "PLUGIN_INVENTORY"}, Required: true, }, &cli.StringSliceFlag{ Name: "playbook", - Usage: "list of playbooks to apply", + Aliases: []string{"p"}, + Usage: "List of playbooks to apply.", EnvVars: []string{"ANSIBLE_PLAYBOOK", "INPUT_PLAYBOOK", "PLUGIN_PLAYBOOK"}, Required: true, }, &cli.StringFlag{ - Name: "limit,l", - Usage: "further limit selected hosts to an additional pattern", + Name: "limit", + Aliases: []string{"l"}, + Usage: "Limits the playbook execution to a specific group of hosts.", EnvVars: []string{"ANSIBLE_LIMIT", "INPUT_LIMIT", "PLUGIN_LIMIT"}, }, &cli.StringFlag{ Name: "skip-tags", - Usage: "only run plays and tasks whose tags do not match these values", + Usage: "Only run plays and tasks whose tags do not match these values.", EnvVars: []string{"ANSIBLE_SKIP_TAGS", "INPUT_SKIP_TAGS", "PLUGIN_SKIP_TAGS"}, }, &cli.StringFlag{ Name: "start-at-task", - Usage: "start the playbook at the task matching this name", + Usage: "Start the playbook at the task matching this name.", EnvVars: []string{"ANSIBLE_START_AT_TASK", "INPUT_START_AT_TASK", "PLUGIN_START_AT_TASK"}, }, &cli.StringFlag{ - Name: "tags,t", - Usage: "only run plays and tasks tagged with these values", + Name: "tags", + Aliases: []string{"t"}, + Usage: "Executes only tasks and plays with specified tags.", EnvVars: []string{"ANSIBLE_TAGS", "INPUT_TAGS", "PLUGIN_TAGS"}, }, &cli.StringSliceFlag{ Name: "extra-vars", - Usage: "set additional variables as key=value", + Aliases: []string{"e"}, + Usage: "Sets additional variables in a key=value format for the playbook.", EnvVars: []string{"ANSIBLE_EXTRA_VARS", "INPUT_EXTRA_VARS", "PLUGIN_EXTRA_VARS"}, }, &cli.StringSliceFlag{ - Name: "module-path,M", - Usage: "prepend paths to module library", + Name: "module-path", + Aliases: []string{"M"}, + Usage: "Prepends specified paths to the module library path list.", EnvVars: []string{"ANSIBLE_MODULE_PATH", "INPUT_MODULE_PATH", "PLUGIN_MODULE_PATH"}, }, &cli.BoolFlag{ - Name: "check,C", - Usage: "run a check, do not apply any changes", + Name: "check", + Aliases: []string{"C"}, + Usage: "Executes a dry run, showing what changes would be made without making them.", EnvVars: []string{"ANSIBLE_CHECK", "INPUT_CHECK", "PLUGIN_CHECK"}, }, &cli.BoolFlag{ - Name: "diff,D", - Usage: "when changing (small) files and templates, show the differences in those files; works great with –check", + Name: "diff", + Aliases: []string{"D"}, + Usage: "Shows the differences in files and templates when changing them.", EnvVars: []string{"ANSIBLE_DIFF", "INPUT_DIFF", "PLUGIN_DIFF"}, }, &cli.BoolFlag{ Name: "flush-cache", - Usage: "clear the fact cache for every host in inventory", + Usage: "Clears the fact cache for every host in the inventory.", EnvVars: []string{"ANSIBLE_FLUSH_CACHE", "INPUT_FLUSH_CACHE", "PLUGIN_FLUSH_CACHE"}, }, &cli.BoolFlag{ Name: "force-handlers", - Usage: "run handlers even if a task fails", + Usage: "Runs all handlers even if a task fails.", EnvVars: []string{"ANSIBLE_FORCE_HANDLERS", "INPUT_FORCE_HANDLERS", "PLUGIN_FORCE_HANDLERS"}, }, &cli.BoolFlag{ Name: "list-hosts", - Usage: "outputs a list of matching hosts", + Usage: "Outputs a list of matching hosts.", EnvVars: []string{"ANSIBLE_LIST_HOSTS", "INPUT_LIST_HOSTS", "PLUGIN_LIST_HOSTS"}, }, &cli.BoolFlag{ Name: "list-tags", - Usage: "list all available tags", + Usage: "List all available tags.", EnvVars: []string{"ANSIBLE_LIST_TAGS", "INPUT_LIST_TAGS", "PLUGIN_LIST_TAGS"}, }, &cli.BoolFlag{ Name: "list-tasks", - Usage: "list all tasks that would be executed", + Usage: "List all tasks that would be executed.", EnvVars: []string{"ANSIBLE_LIST_TASKS", "INPUT_LIST_TASKS", "PLUGIN_LIST_TASKS"}, }, &cli.BoolFlag{ Name: "syntax-check", - Usage: "perform a syntax check on the playbook", + Usage: "Performs a syntax check on the playbook, without executing it.", EnvVars: []string{"ANSIBLE_SYNTAX_CHECK", "INPUT_SYNTAX_CHECK", "PLUGIN_SYNTAX_CHECK"}, }, &cli.IntFlag{ - Name: "forks,f", - Usage: "specify number of parallel processes to use", + Name: "forks", + Aliases: []string{"f"}, + Usage: "Defines the number of parallel processes to use during playbook execution.", EnvVars: []string{"ANSIBLE_FORKS", "INPUT_FORKS", "PLUGIN_FORKS"}, Value: 5, }, &cli.StringFlag{ Name: "vault-id", - Usage: "the vault identity to use", + Usage: "Specifies the identity to use when accessing an Ansible Vault.", EnvVars: []string{"ANSIBLE_VAULT_ID", "INPUT_VAULT_ID", "PLUGIN_VAULT_ID"}, }, + &cli.StringFlag{ Name: "vault-password", - Usage: "the vault password to use", + Usage: "Sets the password to use for decrypting an Ansible Vault.", EnvVars: []string{"ANSIBLE_VAULT_PASSWORD", "INPUT_VAULT_PASSWORD", "PLUGIN_VAULT_PASSWORD"}, }, &cli.IntFlag{ Name: "verbose", - Usage: "level of verbosity, 0 up to 4", + Aliases: []string{"v"}, + Usage: "Sets the verbosity level, ranging from 0 (minimal output) to 4 (maximum verbosity).", EnvVars: []string{"ANSIBLE_VERBOSE", "INPUT_VERBOSE", "PLUGIN_VERBOSE"}, }, &cli.StringFlag{ Name: "private-key", - Usage: "use this key to authenticate the connection", + Aliases: []string{"k"}, + Usage: "Specifies the SSH private key file for connections.", EnvVars: []string{"ANSIBLE_PRIVATE_KEY", "INPUT_PRIVATE_KEY", "PLUGIN_PRIVATE_KEY"}, }, &cli.StringFlag{ Name: "user", - Usage: "connect as this user", + Aliases: []string{"u"}, + Usage: "Defines the username for making connections.", EnvVars: []string{"ANSIBLE_USER", "INPUT_USER", "PLUGIN_USER"}, }, &cli.StringFlag{ Name: "connection", - Usage: "connection type to use", + Aliases: []string{"c"}, + Usage: "Sets the type of connection to use (e.g., SSH).", EnvVars: []string{"ANSIBLE_CONNECTION", "INPUT_CONNECTION", "PLUGIN_CONNECTION"}, }, &cli.IntFlag{ Name: "timeout", - Usage: "override the connection timeout in seconds", + Aliases: []string{"T"}, + Usage: "Overrides the default connection timeout in seconds.", EnvVars: []string{"ANSIBLE_TIMEOUT", "INPUT_TIMEOUT", "PLUGIN_TIMEOUT"}, }, &cli.StringFlag{ Name: "ssh-common-args", - Usage: "specify common arguments to pass to sftp/scp/ssh", + Usage: "Specifies common arguments to pass to all SSH-based connection methods (SSH, SCP, SFTP).", EnvVars: []string{"ANSIBLE_SSH_COMMON_ARGS", "INPUT_SSH_COMMON_ARGS", "PLUGIN_SSH_COMMON_ARGS"}, }, &cli.StringFlag{ Name: "sftp-extra-args", - Usage: "specify extra arguments to pass to sftp only", + Usage: "Provides extra arguments to pass only to SFTP.", EnvVars: []string{"ANSIBLE_SFTP_EXTRA_ARGS", "INPUT_SFTP_EXTRA_ARGS", "PLUGIN_SFTP_EXTRA_ARGS"}, }, &cli.StringFlag{ Name: "scp-extra-args", - Usage: "specify extra arguments to pass to scp only", + Usage: "Provides extra arguments to pass only to SCP.", EnvVars: []string{"ANSIBLE_SCP_EXTRA_ARGS", "INPUT_SCP_EXTRA_ARGS", "PLUGIN_SCP_EXTRA_ARGS"}, }, &cli.StringFlag{ Name: "ssh-extra-args", - Usage: "specify extra arguments to pass to ssh only", + Usage: "Provides extra arguments to pass only to SSH.", EnvVars: []string{"ANSIBLE_SSH_EXTRA_ARGS", "INPUT_SSH_EXTRA_ARGS", "PLUGIN_SSH_EXTRA_ARGS"}, }, &cli.BoolFlag{ Name: "become", - Usage: "run operations with become", + Aliases: []string{"b"}, + Usage: "Enables privilege escalation, allowing operations to run as another user.", EnvVars: []string{"ANSIBLE_BECOME", "INPUT_BECOME", "PLUGIN_BECOME"}, }, &cli.StringFlag{ Name: "become-method", - Usage: "privilege escalation method to use", + Usage: "Specifies the method to use for privilege escalation (e.g., sudo).", EnvVars: []string{"ANSIBLE_BECOME_METHOD", "INPUT_BECOME_METHOD", "PLUGIN_BECOME_METHOD"}, }, &cli.StringFlag{ Name: "become-user", - Usage: "run operations as this user", + Usage: "Sets the user to impersonate when using privilege escalation.", EnvVars: []string{"ANSIBLE_BECOME_USER", "INPUT_BECOME_USER", "PLUGIN_BECOME_USER"}, }, }, @@ -210,39 +306,55 @@ func main() { func run(c *cli.Context) error { playbook := &ansible.AnsiblePlaybook{ Config: ansible.Config{ - GalaxyFile: c.String("galaxy-file"), - GalaxyForce: c.Bool("galaxy-force"), - Inventories: c.StringSlice("inventory"), - Playbooks: c.StringSlice("playbook"), - Limit: c.String("limit"), - SkipTags: c.String("skip-tags"), - StartAtTask: c.String("start-at-task"), - Tags: c.String("tags"), - ExtraVars: c.StringSlice("extra-vars"), - ModulePath: c.StringSlice("module-path"), - Check: c.Bool("check"), - Diff: c.Bool("diff"), - FlushCache: c.Bool("flush-cache"), - ForceHandlers: c.Bool("force-handlers"), - ListHosts: c.Bool("list-hosts"), - ListTags: c.Bool("list-tags"), - ListTasks: c.Bool("list-tasks"), - SyntaxCheck: c.Bool("syntax-check"), - Forks: c.Int("forks"), - VaultID: c.String("vailt-id"), - VaultPassword: c.String("vault-password"), - Verbose: c.Int("verbose"), - PrivateKey: c.String("private-key"), - User: c.String("user"), - Connection: c.String("connection"), - Timeout: c.Int("timeout"), - SSHCommonArgs: c.String("ssh-common-args"), - SFTPExtraArgs: c.String("sftp-extra-args"), - SCPExtraArgs: c.String("scp-extra-args"), - SSHExtraArgs: c.String("ssh-extra-args"), - Become: c.Bool("become"), - BecomeMethod: c.String("become-method"), - BecomeUser: c.String("become-user"), + GalaxyFile: c.String("galaxy-file"), + GalaxyForce: c.Bool("galaxy-force"), + GalaxyAPIKey: c.String("galaxy-api-key"), + GalaxyAPIServerURL: c.String("galaxy-api-server-url"), + GalaxyCollectionsPath: c.String("galaxy-collections-path"), + GalaxyDisableGPGVerify: c.Bool("galaxy-disable-gpg-verify"), + GalaxyForceWithDeps: c.Bool("galaxy-force-with-deps"), + GalaxyIgnoreCerts: c.Bool("galaxy-ignore-certs"), + GalaxyIgnoreSignatureStatusCodes: c.StringSlice("galaxy-ignore-signature-status-codes"), + GalaxyKeyring: c.String("galaxy-keyring"), + GalaxyOffline: c.Bool("galaxy-offline"), + GalaxyPre: c.Bool("galaxy-pre"), + GalaxyRequiredValidSignatureCount: c.Int("galaxy-required-valid-signature-count"), + GalaxyRequirementsFile: c.String("galaxy-requirements-file"), + GalaxySignature: c.String("galaxy-signature"), + GalaxyTimeout: c.Int("galaxy-timeout"), + GalaxyUpgrade: c.Bool("galaxy-upgrade"), + GalaxyNoDeps: c.Bool("galaxy-no-deps"), + Inventories: c.StringSlice("inventory"), + Playbooks: c.StringSlice("playbook"), + Limit: c.String("limit"), + SkipTags: c.String("skip-tags"), + StartAtTask: c.String("start-at-task"), + Tags: c.String("tags"), + ExtraVars: c.StringSlice("extra-vars"), + ModulePath: c.StringSlice("module-path"), + Check: c.Bool("check"), + Diff: c.Bool("diff"), + FlushCache: c.Bool("flush-cache"), + ForceHandlers: c.Bool("force-handlers"), + ListHosts: c.Bool("list-hosts"), + ListTags: c.Bool("list-tags"), + ListTasks: c.Bool("list-tasks"), + SyntaxCheck: c.Bool("syntax-check"), + Forks: c.Int("forks"), + VaultID: c.String("vailt-id"), + VaultPassword: c.String("vault-password"), + Verbose: c.Int("verbose"), + PrivateKey: c.String("private-key"), + User: c.String("user"), + Connection: c.String("connection"), + Timeout: c.Int("timeout"), + SSHCommonArgs: c.String("ssh-common-args"), + SFTPExtraArgs: c.String("sftp-extra-args"), + SCPExtraArgs: c.String("scp-extra-args"), + SSHExtraArgs: c.String("ssh-extra-args"), + Become: c.Bool("become"), + BecomeMethod: c.String("become-method"), + BecomeUser: c.String("become-user"), }, } diff --git a/tests/hosts.yml b/tests/hosts.yml index 7ace559..7052a69 100644 --- a/tests/hosts.yml +++ b/tests/hosts.yml @@ -1,6 +1,6 @@ --- clients: - hosts: - localhost: - vars: - ansible_connection: local + hosts: + localhost: + vars: + ansible_connection: local diff --git a/tests/playbook.yml b/tests/playbook.yml index ac02248..e1cf658 100644 --- a/tests/playbook.yml +++ b/tests/playbook.yml @@ -1,5 +1,6 @@ ---- -- name: facts - hosts: localhost - tasks: - - setup: +--- +- name: Facts + hosts: localhost + tasks: + - name: Setup + ansible.builtin.setup: