iam_role.yml 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. ---
  2. #####
  3. # Instance profiles consist of two parts. The first part is creating a role
  4. # in which the instance has access and will use this role's permissions
  5. # to make API calls on his behalf. This role requires a trust policy
  6. # which links a service (ec2) to the role. This states that this role
  7. # has access to make call ec2 API calls.
  8. # See ../files/trustpolicy.json
  9. #
  10. # Currently openshift-node requires
  11. # access to the AWS API to call describeinstances.
  12. # https://bugzilla.redhat.com/show_bug.cgi?id=1510519
  13. #####
  14. - name: Create an iam role
  15. iam_role:
  16. name: "{{ openshift_aws_launch_config_iam_roles[l_item].name }}"
  17. assume_role_policy_document: "{{ lookup('file','trustpolicy.json') }}"
  18. state: "{{ openshift_aws_iam_role_state | default('present') }}"
  19. loop: "{{ openshift_aws_launch_config_iam_roles | list }}"
  20. loop_control:
  21. loop_var: l_item
  22. retries: 3
  23. delay: 3
  24. #####
  25. # The second part of this task file is linking the role to a policy
  26. # that specifies which calls the role can make to the ec2 API.
  27. # Currently all that is required is DescribeInstances.
  28. # See ../files/describeinstances.json
  29. #####
  30. - name: create an iam policy
  31. iam_policy:
  32. iam_type: role
  33. iam_name: "{{ openshift_aws_launch_config_iam_roles[l_item].name }}"
  34. policy_json: "{{ openshift_aws_launch_config_iam_roles[l_item].policy_json }}"
  35. policy_name: "{{ openshift_aws_launch_config_iam_roles[l_item].policy_name }}"
  36. state: "{{ openshift_aws_iam_role_state | default('present') }}"
  37. register: l_iam_create_policy_out
  38. loop: "{{ openshift_aws_launch_config_iam_roles | list }}"
  39. loop_control:
  40. loop_var: l_item
  41. retries: 3
  42. delay: 3