redhat-cop / automate-tower

Automating Ansible Tower with Ansible (or the like)
15 stars 8 forks source link

RFE: add support to roll out license file #5

Open pcfe opened 5 years ago

pcfe commented 5 years ago

it would be nice if this role was able to roll out a license file.

FWIW, at https://docs.ansible.com/ansible-tower/latest/html/administration/configure_tower_in_tower.html#license I found instructions how to do this via webUI

pcfe commented 5 years ago

note to self, based on a playbook Eric and I used at another customer

    - name: 'Copy tower-license (must contain "eula_accepted": true)'
      copy:
        src: "{{ tower_license }}"
        dest: "{{ base_copy_dir }}/"
    - name: create configuration file /root/.tower_cli.cfg
      copy:
        content: |
          [general]
          host = localhost
          username = {{ tower_username }}
          password = {{ tower_password }}
        dest: "/root/.tower_cli.cfg"
        mode: 0600
    - name: activate tower
      shell: "tower-cli setting modify LICENSE @{{ base_copy_dir }}/{{ tower_license | basename }}"
      when:  tower_license is defined

will need to add;

pcfe commented 5 years ago

ah, just occurred to me that this Issue and #4 are mutually exclusive. @ericzolf please pick one and close the other as WONTFIX

vvaldez commented 5 years ago

If it helps, we use the URI module to post the license to Tower: https://github.com/vvaldez/ansible-ami-builder/blob/master/roles/ami_config/tasks/profiles/tower/setup.yml#L23

- name: Post Tower license
  uri:
    url: https://{{ inventory_hostname }}/api/v2/config/
    method: POST
    validate_certs: no
    headers:
      Content-Type: "application/json"
      Accept: "application/json"
    force_basic_auth: yes
    user: "{{ tower_username }}"
    password: "{{ tower_password }}"
    body: '{{ lookup("file", tower_license) }}'
    body_format: json