- How to format and mount a block device (and only if a variable is defined):
250-mount-longhorn.yaml# Example snippet: - name: Format the device filesystem: fstype: ext4 dev: "{{ longhorn_device }}" when: longhorn_device is defined
- How to ask "are you sure you want to continue etc":
399-uninstall.yaml# Example snippet: - name: Confirm uninstallation pause: prompt: "Are you sure you want to uninstall RKE2 from all nodes? This will DELETE ALL YOUR DATA. Type 'yes' to continue" register: confirmation failed_when: confirmation.user_input != "yes"
- How to get the name of the first host from a group:
332-more-controllers.yaml,342-workers.yamlatdelegate_to# Example snippet: - name: Copy kubeconfig from first controller delegate_to: "{{ groups['controllers'][0] }}" # Task details...
- Run tasks one by one:
330-more-controllers.yamlatserial# Example snippet: - hosts: controllers[1:] serial: 1 # Task details...
- Using tags to selectively run parts of playbooks
- Using variables to enable/disable features
- Using
ignore_errorsandfailed_whenfor graceful failure handling - Using
registerand checking results for conditional execution
- Using
no_log: truefor sensitive information - Managing secrets with Vault integration
- RKE2 installation failures: Check system requirements and network connectivity
- Certificate issues: Verify DNS resolution and firewall settings
- Storage problems: Check device permissions and filesystem status
- Using
ansible -vvvfor verbose output - Checking logs on target hosts
- Using
kubectl describefor detailed resource information
- Follow consistent YAML formatting
- Use descriptive variable names
- Include comments for complex operations
- Test playbooks in a development environment before submitting
- Verify idempotence (playbooks can be run multiple times without errors)
- Test with different OS versions when applicable
- Update relevant documentation when adding new features
- Include examples for new functionality
- Document any new variables or dependencies