lousab
lousab

Reputation: 21

Redirection rules S3 with ansible

I'm quite new to ansible and awscli. I'm tring to play a role to create a bucket as website with index. Everything is ok but i would like to create also the Redirection Rules.

With an aws cli command like:

 - name: Create Bucket
   command: aws s3api create-bucket --bucket myskroto --acl public-read-write  --create-bucket-configuration LocationConstraint=eu-west-1
   become: yes

i'm able to create the desired task but inside ansible i receive an error about finding the bucket.js file. Where should i put this file?

 Unable to load paramfile file://bucket.js: [Errno 2] No such file or directory: 'bucket.js'"

Tring instead to use an asnible module like:

- name: Configure an s3 bucket as a website with index and error pages
  s3_website:
    name: myskroto
    suffix: index.html
    error_key: errors/404.htm
    state: present

everything is ok but i'm not able to populate the Redirection Rules. Which parameter can i use?

Thanks :)

Upvotes: 1

Views: 107

Answers (1)

lousab
lousab

Reputation: 21

Solved. The problem was simply i was calling bucket.js instead of bucket.json. Everything is fixed. I put the file in the same main.yml root.

test_ansible_roles/
├── bucket.json
├── ec2instances
│   ├── README.md
│   ├── defaults
│   │   └── main.yml
│   ├── handlers
│   │   └── main.yml
│   ├── meta
│   │   └── main.yml
│   ├── tasks
│   │   └── main.yml
│   ├── tests
│   │   ├── inventory
│   │   └── test.yml
│   └── vars
│       └── main.yml
├── main.yml
└── s3bucket
    ├── README.md
    ├── defaults
    │   └── main.yml
    ├── handlers
    │   └── main.yml
    ├── meta
    │   └── main.yml
    ├── tasks
    │   └── main.yml
    ├── tests
    │   ├── inventory
    │   └── test.yml
    └── vars
        └── main.yml

Upvotes: 1

Related Questions