forked from ddemlow/ansible_edge_playbooks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
using_hypercore_inventory.yml
86 lines (69 loc) · 4.01 KB
/
using_hypercore_inventory.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
---
- name: Configure VM guest OS of "storeapps" group directly ansible connection using HyperCore dynamic inventory
hosts: pharmacy
gather_facts: true
become: yes
strategy: free # free #allows each cluster to start next task before all clusters have finished current task
tasks:
- name: Wait for ssh connection to guest
ansible.builtin.wait_for_connection:
delay: 5
timeout: 120
- name: Start docker container
community.docker.docker_container:
name: cms-app
image: quay.io/justinc1_github/django-cms:1
state: started #stopped to stop, started absent
restart_policy: on-failure
ports:
- "80:80"
- name: Show link to web dashboard
ansible.builtin.debug:
msg: "Web dashboard is at http://{{ hostvars[inventory_hostname]['ansible_host'] }} "
# - name: output hostnames
# ansible.builtin.debug:
# name: "{{ inventory_hostname }}"
# - name: remove nginx from guest OS - if present
# ansible.builtin.package:
# name: nginx
# state: absent
# - name: Upgrade all apt packages
# apt: upgrade=dist force_apt_get=yes
# - name: Enable nginx on guest OS
# ansible.builtin.service:
# name: nginx
# state: stopped
# - name: Install podman into VM guest OS
# ansible.builtin.apt:
# name: podman
# state: present
# update_cache: true
# - name: Enable podman on guest OS
# ansible.builtin.service:
# name: podman
# state: started
#env:
# ALLOWED_HOSTS: "*"
# generate_systemd:
# container_prefix: cmsapp
#path: /opt
#restart_policy: on-failure
#- name: "Onboard Linux Servers to Azure Arc-enabled servers with Public endpoint connectivity" hosts: all vars: azure: service_principal_id: '3933c163-3dcc-4248-83fc-b1cbe2ee6865' service_principal_secret: 'INSERT-SERVICE-PRINCIPAL-SECRET' resource_group: 'AzureArcTest' tenant_id: '76d4c62a-a9ca-4dc2-9187-e2cc4d9abe7f' subscription_id: 'eb08cfa9-a0c3-4c8e-a834-b98dc83dd1e6' location: 'eastus' tasks: - name: {"checkIfdownloaded"} stat: path: /usr/bin/azcmagent get_attributes: False get_checksum: False register: azcmagent_lnx_downloaded when: ansible_system == 'Linux' - name: {"downloadConnectedMachineAgentLinuxANS"} become: yes get_url: url: https://aka.ms/azcmagent dest: ~/install_linux_azcmagent.sh mode: '700' when: (ansible_system == 'Linux') and (azcmagent_lnx_downloaded.stat.exists == false) - name: {"installConnectedMachineAgent"} become: yes shell: bash ~/install_linux_azcmagent.sh when: (ansible_system == 'Linux') and (not azcmagent_lnx_downloaded.stat.exists) - name: {"checkConnection"} become: true command: cmd: azcmagent check register: azcmagent_lnx_connected ignore_errors: yes when: ansible_system == 'Linux' failed_when: (azcmagent_lnx_connected.rc not in [ 0, 16 ]) changed_when: False - name: {"connectToAzureArc"} become: yes shell: azcmagent connect --service-principal-id "{{ azure.service_principal_id }}" --service-principal-secret "{{ azure.service_principal_secret }}" --resource-group "{{ azure.resource_group }}" --tenant-id "{{ azure.tenant_id }}" --location "{{ azure.location }}" --subscription-id "{{ azure.subscription_id }}" --tags "Platform=HyperCore" when: (ansible_system == 'Linux') and (azcmagent_lnx_connected.rc is defined and azcmagent_lnx_connected.rc != 0)
# - name: Start application
# containers.podman.podman_container:
# name: cms-app
# image: quay.io/justinc1_github/django-cms:1
# state: started
# restart_policy: on-failure
# ports:
# - "80:80"
# #env:
# # ALLOWED_HOSTS: "*"
# generate_systemd:
# # container_prefix: cmsapp
# path: /opt
# restart_policy: on-failure
# - name: Enable container as service
# ansible.builtin.command:
# cmd: systemctl enable /opt/container-cms-app.service
# creates: /etc/systemd/system/container-cms-app.service