- hosts: localhost connection: local vars: # Set True to activate IM in single site more (OpenNebula sites) SINGLE_SITE: False # Hostname of the OpenNebula API server SINGLE_SITE_HOST: onserver.domain.com # URL of the IAM TTS server TTS_URL: https://localhost:8443 tasks: - name: Yum install epel-release action: yum pkg=epel-release state=installed when: ansible_os_family == "RedHat" - name: Install libselinux-python in RH action: yum pkg=libselinux-python state=installed when: ansible_os_family == "RedHat" - name: Ubuntu install Ansible requisites with apt apt: name=python-pip,python-jinja2,sshpass,openssh-client,unzip,python-mysqldb,python-sqlite update_cache=yes when: ansible_distribution == "Ubuntu" - apt_key: url=https://repo.indigo-datacloud.eu/repository/RPM-GPG-KEY-indigodc state=present when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version|int >= 14 ignore_errors: yes register: indigo_apt_key - shell: wget -qO - https://repo.indigo-datacloud.eu/repository/RPM-GPG-KEY-indigodc | sudo apt-key add - warn=false when: indigo_apt_key is failed - name: Ubuntu install indigo 2 repo apt: deb=https://repo.indigo-datacloud.eu/repository/indigo/2/ubuntu/dists/xenial/main/binary-amd64/indigodc-release_2.0.0-1_amd64.deb when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version|int >= 14 - name: Apt-get update apt: update_cache=yes when: ansible_os_family == "Debian" - name: Ubuntu install IM and Ansible with apt apt: name=python-im,ansible force=yes when: ansible_distribution == "Ubuntu" - name: RH indigo repos yum: state=present name=https://repo.indigo-datacloud.eu/repository/indigo/2/centos7/x86_64/base/indigodc-release-2.0.0-1.el7.centos.noarch.rpm when: ansible_os_family == "RedHat" - rpm_key: state=present key=https://repo.indigo-datacloud.eu/repository/RPM-GPG-KEY-indigodc when: ansible_os_family == "RedHat" - name: RH7 install Ansible with yum yum: name=IM,ansible,python-pip,python-jinja2,sshpass,openssh-clients,unzip,MySQL-python,python-sqlite3dbm when: ansible_os_family == "RedHat" - name: Install Azure libraries pip: executable=pip name=msrest,msrestazure,azure-common,azure-mgmt-storage,azure-mgmt-compute,azure-mgmt-network,azure-mgmt-resource,azure-mgmt-dns,azure-storage ################################################ Configure Ansible ################################################### - name: Create /etc/ansible file: path=/etc/ansible state=directory - name: Set host_key_checking to false in ansible.cfg ini_file: dest=/etc/ansible/ansible.cfg section=defaults option=host_key_checking value=False - name: Set nocolor to 1 in ansible.cfg to avoid strange chars in Ansible outputs ini_file: dest=/etc/ansible/ansible.cfg section=defaults option=nocolor value=1 - name: Set timeout to 30 in ansible.cfg to avoid problems with some VMs ini_file: dest=/etc/ansible/ansible.cfg section=defaults option=timeout value=30 - name: Set transport to ssh in ansible.cfg ini_file: dest=/etc/ansible/ansible.cfg section=defaults option=transport value=ssh when: ansible_os_family == "Debian" or (ansible_os_family == "RedHat" and ansible_distribution_major_version|int >= 6) or (ansible_os_family == "Suse" and ansible_distribution_major_version|int >= 10) - name: Set transport to smart in ansible.cfg ini_file: dest=/etc/ansible/ansible.cfg section=defaults option=transport value=smart when: (ansible_os_family == "RedHat" and ansible_distribution_major_version|int < 6) or (ansible_os_family == "Suse" and ansible_distribution_major_version|int < 10) - name: Change ssh_args to set ControlPersist to 15 min in ansible.cfg ini_file: dest=/etc/ansible/ansible.cfg section=ssh_connection option=ssh_args value="-o ControlMaster=auto -o ControlPersist=900s" when: ansible_os_family == "Debian" or (ansible_os_family == "RedHat" and ansible_distribution_major_version|int >= 7) or (ansible_os_family == "Suse" and ansible_distribution_major_version|int >= 12) - name: Change ssh_args to remove ControlPersist in REL 6 and older in ansible.cfg ini_file: dest=/etc/ansible/ansible.cfg section=ssh_connection option=ssh_args value="" when: (ansible_os_family == "RedHat" and ansible_distribution_major_version|int < 7) or (ansible_os_family == "Suse" and ansible_distribution_major_version|int < 12) - name: Activate SSH pipelining in ansible.cfg ini_file: dest=/etc/ansible/ansible.cfg section=ssh_connection option=pipelining value=True ################################################ Configure IM ################################################### - name: Activate SINGLE_SITE in the IM ini_file: dest=/etc/im/im.cfg section=im option=SINGLE_SITE value=True when: SINGLE_SITE - name: Set SINGLE_SITE_AUTH_HOST in the IM ini_file: dest=/etc/im/im.cfg section=im option=SINGLE_SITE_AUTH_HOST value="http://{{SINGLE_SITE_HOST}}:2633" when: SINGLE_SITE - name: Set SINGLE_SITE_IMAGE_URL_PREFIX in the IM ini_file: dest=/etc/im/im.cfg section=im option=SINGLE_SITE_IMAGE_URL_PREFIX value="one://{{SINGLE_SITE_HOST}}/" when: SINGLE_SITE - name: Set TTS_URL in the IM ini_file: dest=/etc/im/im.cfg section=OpenNebula option=TTS_URL value="{{TTS_URL}}"