Nagarjuna D N Nagarjuna D N - 4 months ago 34
YAML Question

Unable to create aws kinesis stream using ansible module...!

I am trying to create aws kinesis stream using ansible and I got some example module snippets from here

My modified snippet kinesis.yml is here to create kinesis stream on specific region:

- hosts: localhost
connection: local
gather_facts: no
vars:
#aws region to create kinesis
region: ap-south-1
tasks:
- name: Set up Kinesis Stream with 2 shards and wait for the stream to become ACTIVE
kinesis_stream:
name: test-stream
shards: 2
wait: yes
wait_timeout: 600
region: "{{ region }}"
register: test_stream


I think some where I messud up with the way we can define kinesis module and I got the below error:

centos]# ansible-playbook -vvvv kinesis.yml
No config file found; using defaults
ERROR! no action detected in task. This often indicates a misspelled module name, or incorrect module path.

The error appears to have been in '/home/centos/kinesis.yml': line 4, column 7, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

tasks:
- name: Set up Kinesis Stream with 2 shards and wait for the stream to become ACTIVE
^ here


I have configured my aws console access keys with boto.
Please let me know is there a right way to define ansible playbook to create a kinesis on specific aws region.?

Answer

Finally I achieved by using aws cli with ansible. On a bit more exploring to ansible, it also supports a command line options. So, we can pass aws cli commands that works with ansible.

Here is my sample module snippet:

---
- hosts: localhost
  connection: local
  gather_facts: no
  vars:
    streamName: test-stream
    shardCount: 2
  tasks:
    - name: Create Kinesis Sream
      command: aws kinesis create-stream --stream-name {{streamName}} --shard-count {{shardCount}}
      register: kinesis

Using this AWS CLI approach we can quickly add more AWS functions/services to our Ansible playbook.