ansible-collections / ansible-collections/google.cloud
skip_initial_version_creation in gcp_kms_crypto_key doesn't have a default
- Dominant language
- Python
- Stars
- 105
- Forks
- 144
- Avg merge
- 5d 10h
- Merged PRs (30d)
- 4
Description
##### SUMMARY
Documentation suggests that field `skip_initial_version_creation` in gcp_kms_crypto_key is not required, yet it doesn't have a default. Which is why a call to gcp_kms_crypto_key fails when the value for this field is not specified.
##### ISSUE TYPE
- Bug Report
##### COMPONENT NAME
gcp_kms_crypto_key
##### ANSIBLE VERSION
```paste below
ansible 2.10.6
config file = /etc/ansible/ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/lib/python3.7/site-packages/ansible
executable location = /usr/local/bin/ansible
python version = 3.7.10 (default, Feb 16 2021, 19:37:20) [GCC 8.3.0]
```
##### CONFIGURATION
```paste below
ANSIBLE_SSH_ARGS(/etc/ansible/ansible.cfg) = -o ControlMaster=auto -o ControlPersist=30m -o StrictHostKeyChecking=no -o User=xxx -o UserKnownHostsFile=/dev/null
ANSIBLE_SSH_CONTROL_PATH(/etc/ansible/ansible.cfg) = ~/.ssh/%%C
DEFAULT_TIMEOUT(/etc/ansible/ansible.cfg) = 60
INVENTORY_ENABLED(/etc/ansible/ansible.cfg) = ['host_list', 'gcp_compute']
```
##### OS / ENVIRONMENT
Docker `python:3.7-slim`
##### STEPS TO REPRODUCE
```yaml
- name: create a crypto key
google.cloud.gcp_kms_crypto_key:
name: "{{ cloud_kms_key_name }}"
key_ring: projects/{{ host.project_id }}/locations/{{ region }}/keyRings/{{ cloud_kms_keyring_name }}
project: "{{ host.project_id }}"
auth_kind: serviceaccount
service_account_file: "{{ credentials_file }}"
state: present
```
##### EXPECTED RESULTS
Created a crypto key
##### ACTUAL RESULTS
Fails to run the command because the field value is not provided
```paste below
fatal: [localhost]: FAILED! => {"changed": false, "msg": "GCP returned error: {'error': {'code': 400, 'message': \"Invalid value at 'skip_initial_version_creation' (TYPE_BOOL), \", 'status': 'INVALID_ARGUMENT', 'details': [{'@type': 'type.googleapis.com/google.rpc.BadRequest', 'fieldViolations': [{'field': 'skip_initial_version_creation', 'description': \"Invalid value at 'skip_initial_version_creation' (TYPE_BOOL), \"}]}]}}"}
```
Contributor guide
Research direction
Start with the gcp_kms_crypto_key module's argument definition and reproduce the supplied playbook with skip_initial_version_creation omitted. Check how the unset value is passed to GCP and add or update the component's test coverage so the playbook creates the crypto key successfully without that field.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ansible, gcp, python
- Domain
- cloud, devops
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 74/100