Skip to content

feat: Add Ansible tasks for kubectl installation and bash autocompletion #27

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

Merged
merged 3 commits into from
May 24, 2025

Conversation

maheshrijal
Copy link
Owner

This commit introduces new Ansible tasks to automate the setup of kubectl:

  • Creates tasks/kubectl.yml with tasks to:

    • Download the latest stable kubectl binary.
    • Move the kubectl binary to /usr/local/bin.
    • Install the bash-completion package.
    • Generate and install the kubectl bash completion script to /etc/bash_completion.d/kubectl.
  • Includes the tasks/kubectl.yml into the main local.yml playbook.

  • Ensures the Ansible code adheres to linting best practices as per ansible-lint.

google-labs-jules bot and others added 3 commits May 24, 2025 17:47
This commit introduces new Ansible tasks to automate the setup of kubectl:

- Creates `tasks/kubectl.yml` with tasks to:
    - Download the latest stable kubectl binary.
    - Move the kubectl binary to `/usr/local/bin`.
    - Install the `bash-completion` package.
    - Generate and install the kubectl bash completion script to `/etc/bash_completion.d/kubectl`.

- Includes the `tasks/kubectl.yml` into the main `local.yml` playbook.
- Ensures the Ansible code adheres to linting best practices as per `ansible-lint`.
This commit refines the Ansible tasks for setting up kubectl:

- Modifies `tasks/kubectl.yml` to install `kubectl` using native package
  managers (`apt` for Debian-based, `dnf` for Red Hat-based systems)
  instead of direct binary download. This aligns with Kubernetes
  documentation and leverages system package management.
- Updates bash completion setup in `~/.bashrc` to:
    - Add the alias `k=kubectl`.
    - Source kubectl completion using `source <(kubectl completion bash)`.
    - Enable completion for the `k` alias using `complete -o default -F __start_kubectl k`.
- Ensures Ansible code adheres to `ansible-lint` best practices,
  including the use of FQCN for modules (e.g., `ansible.builtin.dnf`).
@maheshrijal maheshrijal marked this pull request as ready for review May 24, 2025 18:08
@maheshrijal maheshrijal merged commit 3d06f44 into main May 24, 2025
2 checks passed
@maheshrijal maheshrijal deleted the feat-ansible-kubectl-setup branch May 24, 2025 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant