main.yml 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. ---
  2. - name: fail when params are not set
  3. fail:
  4. msg: Please specify the role parameters.
  5. when:
  6. - r_openshift_aws_launch_config_cluseterid is undefined
  7. - r_openshift_aws_launch_config_type is undefined
  8. - r_openshift_aws_launch_config_region is undefined
  9. - r_openshift_aws_launch_config is undefined
  10. - name: fetch the security groups for launch config
  11. ec2_group_facts:
  12. filters:
  13. group-name:
  14. - "{{ r_openshift_aws_launch_config_clusterid }}" # default sg
  15. - "{{ r_openshift_aws_launch_config_clusterid }}_{{ r_openshift_aws_launch_config_type }}" # node type sg
  16. - "{{ r_openshift_aws_launch_config_clusterid }}_{{ r_openshift_aws_launch_config_type }}_k8s" # node type sg k8s
  17. region: "{{ r_openshift_aws_launch_config_region }}"
  18. register: ec2sgs
  19. # Create the scale group config
  20. - name: Create the node scale group config
  21. ec2_lc:
  22. name: "{{ r_openshift_aws_launch_config_name }}"
  23. region: "{{ r_openshift_aws_launch_config_region }}"
  24. image_id: "{{ r_openshift_aws_launch_config_custom_image if 'ami-' in r_openshift_aws_launch_config_custom_image else r_openshift_aws_launch_config[r_openshift_aws_launch_config_type].ami }}"
  25. instance_type: "{{ r_openshift_aws_launch_config[r_openshift_aws_launch_config_type].instance_type }}"
  26. security_groups: "{{ ec2sgs.security_groups | map(attribute='group_id')| list }}"
  27. user_data: |-
  28. #cloud-config
  29. {% if r_openshift_aws_launch_config_type != 'master' %}
  30. write_files:
  31. - path: /root/csr_kubeconfig
  32. owner: root:root
  33. permissions: '0640'
  34. content: {{ r_openshift_aws_launch_config_bootstrap_token | default('') | to_yaml }}
  35. - path: /root/openshift_settings
  36. owner: root:root
  37. permissions: '0640'
  38. content:
  39. openshift_type: "{{ r_openshift_aws_launch_config_type }}"
  40. runcmd:
  41. - [ systemctl, enable, atomic-openshift-node]
  42. - [ systemctl, start, atomic-openshift-node]
  43. {% endif %}
  44. key_name: "{{ r_openshift_aws_launch_config.ssh_key_name }}"
  45. ebs_optimized: False
  46. volumes: "{{ r_openshift_aws_launch_config[r_openshift_aws_launch_config_type].volumes }}"
  47. assign_public_ip: True
  48. register: test