main.yml 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. # Copyright 2020 Dell Inc. or its subsidiaries. All Rights Reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. ---
  15. - name: Set Facts
  16. set_fact:
  17. ansible_ssh_common_args: '-o StrictHostKeyChecking=no'
  18. - name: Disable key host checking
  19. replace:
  20. path: /etc/ansible/ansible.cfg
  21. regexp: '#host_key_checking = False'
  22. replace: 'host_key_checking = False'
  23. - name: Disable host key checking
  24. replace:
  25. path: /etc/ssh/ssh_config
  26. regexp: '# StrictHostKeyChecking ask'
  27. replace: 'StrictHostKeyChecking no'
  28. - name: Check if provisioned host file exists
  29. stat:
  30. path: "{{ role_path }}/files/provisioned_hosts.yml"
  31. register: provisioned_file_result
  32. - name: Include vars file of common role
  33. include_vars: "{{ role_path }}/../common/vars/main.yml"
  34. - name: Include vars file of web_ui role
  35. include_vars: "{{ role_path }}/../web_ui/vars/main.yml"
  36. - name: Update inventory file
  37. block:
  38. - name: Decrpyt input_config.yml
  39. command: >-
  40. ansible-vault decrypt {{ input_config_filename }}
  41. --vault-password-file roles/common/files/{{ vault_filename }}
  42. changed_when: false
  43. - name: Include variable file input_config.yml
  44. include_vars: "{{ input_config_filename }}"
  45. - name: Save input variables from file
  46. set_fact:
  47. cobbler_password: "{{ provision_password }}"
  48. - name: Encrypt input config file
  49. command: >-
  50. ansible-vault encrypt {{ input_config_filename }}
  51. --vault-password-file roles/common/files/{{ vault_filename }}
  52. - name: add hosts with description to inventory file
  53. command: >-
  54. ansible-playbook -i {{ role_path }}/files/provisioned_hosts.yml
  55. {{ role_path }}/files/create_inventory.yml
  56. --extra-vars "cobbler_username={{ cobbler_username }} cobbler_password={{ cobbler_password }}"
  57. ignore_errors: yes
  58. when: provisioned_file_result.stat.exists
  59. - name: push inventory to AWX
  60. command: awx-manage inventory_import --inventory-name {{ omnia_inventory_name }} --source {{ role_path }}/files/inventory
  61. changed_when: no