joelbirchler
2020-02-28 222a14f6e10ed54e0b22b58a45366b443323aa14
WIP first attempt at gitlab and tower setup in a workload
6 files modified
2 files renamed
398 ■■■■ changed files
ansible/configs/ansible-skylight/post_software.yml 112 ●●●● patch | view | raw | blame | history
ansible/configs/ansible-skylight/software.yml 263 ●●●● patch | view | raw | blame | history
ansible/configs/ansible-skylight/workloads.yml 10 ●●●● patch | view | raw | blame | history
ansible/roles/agnosticd-workload/defaults/main.yml 1 ●●●● patch | view | raw | blame | history
ansible/roles/agnosticd-workload/tasks/gitlab.yml patch | view | raw | blame | history
ansible/roles/agnosticd-workload/tasks/tower.yml patch | view | raw | blame | history
ansible/roles/agnosticd-workload/tasks/workload.yml 6 ●●●● patch | view | raw | blame | history
ansible/roles/skylight-ansible-tower/tasks/main.yml 6 ●●●● patch | view | raw | blame | history
ansible/configs/ansible-skylight/post_software.yml
@@ -7,69 +7,69 @@
    - debug:
        msg: "Post-Software tasks Started"
# - name: Copy files to workstation
#   hosts: workstations
#   tasks:
#     - name: Copy Ansible Inventory for this environment
#       win_copy:
#         src: "{{output_dir}}/hosts-{{ env_type }}-{{ guid }}"
#         dest: "C:\\inventory.ini"
- name: Copy files to workstation
  hosts: workstations
  tasks:
    - name: Copy Ansible Inventory for this environment
      win_copy:
        src: "{{output_dir}}/hosts-{{ env_type }}-{{ guid }}"
        dest: "C:\\inventory.ini"
# - name: PostSoftware flight-check
#   hosts: towers
#   gather_facts: false
#   become: yes
#   tags:
#     - post_flight_check
#   tasks:
#     - name: See if virtualenv is installed
#       stat:
#         path: venv
#       register: virtualenv
- name: PostSoftware flight-check
  hosts: towers
  gather_facts: false
  become: yes
  tags:
    - post_flight_check
  tasks:
    - name: See if virtualenv is installed
      stat:
        path: venv
      register: virtualenv
#     - name: Setup python virtualenv
#       shell: |
#         virtualenv venv
#         source venv/bin/activate
#         pip install ansible requests-credssp pywinrm
#         deactivate
#         exit 0
#       when: not virtualenv.stat.exists
    - name: Setup python virtualenv
      shell: |
        virtualenv venv
        source venv/bin/activate
        pip install ansible requests-credssp pywinrm
        deactivate
        exit 0
      when: not virtualenv.stat.exists
#     - name: Test Ansible connectivity to Windows servers
#       shell: |
#         source venv/bin/activate
#         ansible windows -m win_ping
#       register: ansible_check
#       ignore_errors: true
    - name: Test Ansible connectivity to Windows servers
      shell: |
        source venv/bin/activate
        ansible windows -m win_ping
      register: ansible_check
      ignore_errors: true
#     - debug:
#         var: ansible_check
    - debug:
        var: ansible_check
#     - fail:
#         msg: "Ansible test of tower environment failed"
#       when: ansible_check is failed
    - fail:
        msg: "Ansible test of tower environment failed"
      when: ansible_check is failed
#     - debug:
#         msg: "Post-Software checks completed successfully"
    - debug:
        msg: "Post-Software checks completed successfully"
- name: Include private workloads
  import_playbook: workloads.yml
  
# - name: Provisioning final tasks
#   hosts: localhost
#   connection: local
#   gather_facts: false
#   become: no
#   tasks:
#     - name: Report provisioning status
#       include_role:
#         name: status-report
#       vars:
#         classroom_status: "Classroom ready"
#         status_json: "{{ lookup('template', 'report.j2') }}"
#       when: report_status
#     - name: Stop SSH/Socks proxy for Windows proxying through bastion
#       shell: |
#         ssh -i {{ ssh_key | default(infra_ssh_key) | default(ansible_ssh_private_key_file) | default(default_key_name)}} -o "ControlPath=~/.ssh/cp/ssh-%r@%h:%p" -O exit -p 22 {{hostvars[bastion_hostname].ansible_user}}@{{hostvars[bastion_hostname].public_ip_address}}
#       when: win_connect_method | d('winrm') == 'psrp'
- name: Provisioning final tasks
  hosts: localhost
  connection: local
  gather_facts: false
  become: no
  tasks:
    - name: Report provisioning status
      include_role:
        name: status-report
      vars:
        classroom_status: "Classroom ready"
        status_json: "{{ lookup('template', 'report.j2') }}"
      when: report_status
    - name: Stop SSH/Socks proxy for Windows proxying through bastion
      shell: |
        ssh -i {{ ssh_key | default(infra_ssh_key) | default(ansible_ssh_private_key_file) | default(default_key_name)}} -o "ControlPath=~/.ssh/cp/ssh-%r@%h:%p" -O exit -p 22 {{hostvars[bastion_hostname].ansible_user}}@{{hostvars[bastion_hostname].public_ip_address}}
      when: win_connect_method | d('winrm') == 'psrp'
ansible/configs/ansible-skylight/software.yml
@@ -7,153 +7,144 @@
    - debug:
        msg: "Software tasks Started"
# - name: Report Provisioning Status
#   hosts: localhost
#   connection: local
#   gather_facts: false
#   become: no
#   tasks:
#     - name: Report provisioning status
#       include_role:
#         name: status-report
#       vars:
#         classroom_status: "Servers provisioned 1 of 6"
#         status_json: "{{ lookup('template', 'report.j2') }}"
#       when: report_status
#
# - name: Step 001 software - Configure Active Directory DC
#   hosts: activedirectories
#   gather_facts: true
#   tags:
#     - windows-ad-controller
#   roles:
#     - skylight-windows-ad
- name: Report Provisioning Status
  hosts: localhost
  connection: local
  gather_facts: false
  become: no
  tasks:
    - name: Report provisioning status
      include_role:
        name: status-report
      vars:
        classroom_status: "Servers provisioned 1 of 6"
        status_json: "{{ lookup('template', 'report.j2') }}"
      when: report_status
# - name: Report Provisioning Status
#   hosts: localhost
#   connection: local
#   gather_facts: false
#   become: no
#   tasks:
#     - name: Report provisioning status
#       include_role:
#         name: status-report
#       vars:
#         classroom_status: "Active Directory configured 2 of 6"
#         status_json: "{{ lookup('template', 'report.j2') }}"
#       when: report_status
- name: Step 001 software - Configure Active Directory DC
  hosts: activedirectories
  gather_facts: true
  tags:
    - windows-ad-controller
  roles:
    - skylight-windows-ad
# - name: Step 002 software - Configure Windows Servers
#   hosts:
#     - windows_servers
#     - workstations
#   gather_facts: true
#   tags:
#     - windows-servers
#   roles:
#     - skylight-windows-common
- name: Report Provisioning Status
  hosts: localhost
  connection: local
  gather_facts: false
  become: no
  tasks:
    - name: Report provisioning status
      include_role:
        name: status-report
      vars:
        classroom_status: "Active Directory configured 2 of 6"
        status_json: "{{ lookup('template', 'report.j2') }}"
      when: report_status
# - name: Report Provisioning Status
#   hosts: localhost
#   connection: local
#   gather_facts: false
#   become: no
#   tasks:
#     - name: Report provisioning status
#       include_role:
#         name: status-report
#       vars:
#         classroom_status: "Windows servers configured 3 of 6"
#         status_json: "{{ lookup('template', 'report.j2') }}"
#       when: report_status
- name: Step 002 software - Configure Windows Servers
  hosts:
    - windows_servers
    - workstations
  gather_facts: true
  tags:
    - windows-servers
  roles:
    - skylight-windows-common
# - name: Step 003.1 software - Configure GitLab Host
#   hosts: gitlab
#   become: true
#   gather_facts: true
#   tags:
#     - gitlab
#   roles:
#     - skylight-linux-common
#     - geerlingguy.gitlab
- name: Report Provisioning Status
  hosts: localhost
  connection: local
  gather_facts: false
  become: no
  tasks:
    - name: Report provisioning status
      include_role:
        name: status-report
      vars:
        classroom_status: "Windows servers configured 3 of 6"
        status_json: "{{ lookup('template', 'report.j2') }}"
      when: report_status
# - name: Step 003.2 software - Configure Gitlab Environment
#   hosts: gitlab
#   become: true
#   gather_facts: true
#   tags:
#     - gitlab
#   roles:
#     - skylight-gitlab-env
- name: Step 003.1 software - Configure GitLab Host
  hosts: gitlab
  become: true
  gather_facts: true
  tags:
    - gitlab
  roles:
    - skylight-linux-common
    - geerlingguy.gitlab
# - name: Step 003.3 software - Configure DO417 repos
#   hosts: gitlab
#   become: False
#   gather_facts: False
#   tags:
#     - gitlab
#   roles:
#     - skylight-do417-repos
- name: Step 003.2 software - Configure Gitlab Environment
  hosts: gitlab
  become: true
  gather_facts: true
  tags:
    - gitlab
  roles:
    - skylight-gitlab-env
# - name: Report Provisioning Status
#   hosts: localhost
#   connection: local
#   gather_facts: false
#   become: no
#   tasks:
#     - name: Report provisioning status
#       include_role:
#         name: status-report
#       vars:
#         classroom_status: "Gitlab configured 4 of 6"
#         status_json: "{{ lookup('template', 'report.j2') }}"
#       when: report_status
- name: Report Provisioning Status
  hosts: localhost
  connection: local
  gather_facts: false
  become: no
  tasks:
    - name: Report provisioning status
      include_role:
        name: status-report
      vars:
        classroom_status: "Gitlab configured 4 of 6"
        status_json: "{{ lookup('template', 'report.j2') }}"
      when: report_status
# - name: Step 004 software - Configure Ansible Tower
#   hosts: towers
#   become: true
#   gather_facts: true
#   tags:
#     - ansible-tower
#   roles:
#     - skylight-linux-common
#     - skylight-ansible-tower
- name: Step 004 software - Configure Ansible Tower
  hosts: towers
  become: true
  gather_facts: true
  tags:
    - ansible-tower
  roles:
    - skylight-linux-common
    - skylight-ansible-tower
# - name: Report Provisioning Status
#   hosts: localhost
#   connection: local
#   gather_facts: false
#   become: no
#   tasks:
#     - name: Report provisioning status
#       include_role:
#         name: status-report
#       vars:
#         classroom_status: "Ansible Tower configured 5 of 6"
#         status_json: "{{ lookup('template', 'report.j2') }}"
#       when: report_status
- name: Report Provisioning Status
  hosts: localhost
  connection: local
  gather_facts: false
  become: no
  tasks:
    - name: Report provisioning status
      include_role:
        name: status-report
      vars:
        classroom_status: "Ansible Tower configured 5 of 6"
        status_json: "{{ lookup('template', 'report.j2') }}"
      when: report_status
# - name: Step 005 software - Configure Windows Workstation
#   hosts: workstations
#   gather_facts: true
#   tags:
#     - windows-workstation
#   roles:
#     - skylight-windows-workstation
- name: Step 005 software - Configure Windows Workstation
  hosts: workstations
  gather_facts: true
  tags:
    - windows-workstation
  roles:
    - skylight-windows-workstation
# - name: Report Provisioning Status
#   hosts: localhost
#   connection: local
#   gather_facts: false
#   become: no
#   tasks:
#     - name: Report provisioning status
#       include_role:
#         name: status-report
#       vars:
#         classroom_status: "Windows Workstation configured 6 of 6"
#         status_json: "{{ lookup('template', 'report.j2') }}"
#       when: report_status
- name: Report Provisioning Status
  hosts: localhost
  connection: local
  gather_facts: false
  become: no
  tasks:
    - name: Report provisioning status
      include_role:
        name: status-report
      vars:
        classroom_status: "Windows Workstation configured 6 of 6"
        status_json: "{{ lookup('template', 'report.j2') }}"
      when: report_status
- name: Step 00xxxxx software
  hosts: localhost
ansible/configs/ansible-skylight/workloads.yml
@@ -10,9 +10,9 @@
      include_role:
        name: "{{ item.tmp }}"
      vars:
        ACTION:         "provision"
        workload_name:  "{{ item.name }}"
        git_remote_url: "{{ item.url }}"
        git_path:       "{{ item.path }}"
        git_ssh_key:    "{{ item.ssh_key }}"
        ACTION:                  "provision"
        workload_name:           "{{ item.name }}"
        workload_git_url:        "{{ item.url }}"
        workload_git_path:       "{{ item.path }}"
        workload_ssh_key:        "{{ item.ssh_key }}"
      loop: "{{ private_workloads }}"
ansible/roles/agnosticd-workload/defaults/main.yml
@@ -1,4 +1,3 @@
---
become_override: False
silent: False
ansible/roles/agnosticd-workload/tasks/gitlab.yml
ansible/roles/agnosticd-workload/tasks/tower.yml
ansible/roles/agnosticd-workload/tasks/workload.yml
@@ -1,11 +1,15 @@
---
# Implement your Workload deployment tasks here
- name: Setting up workload
  debug:
    msg: "Setting up workload {{ workload_name }}."
  when: not silent|bool
- name: Setting up GitLab
  include_tasks: gitlab.yml
- name: Setting up Tower
  include_tasks: tower.yml
# Leave this as the last task in the playbook.
- name: workload tasks complete
ansible/roles/skylight-ansible-tower/tasks/main.yml
@@ -180,8 +180,4 @@
- name: Update git to credential timeout after 1 day
  command: git config --global credential.helper 'cache --timeout=86400'
- include_tasks: setup.yml
# Creation of custom DO417 resources
# TODO: where to get these from?
- include_tasks: create-resources.yml
- include_tasks: setup.yml