Skip to content

Commit

Permalink
Add basic ansible. (see #19)
Browse files Browse the repository at this point in the history
  • Loading branch information
soroshsabz committed Mar 19, 2022
1 parent fe52375 commit 653458f
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Deployment/Ansible/playbooks/ansible.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[defaults]
inventory = hosts
remote_user = ssoroosh
port = 22
host_key_checking = False

[privilege_escalation]
become = True
become_method = sudo
become_user = root
become_pass = a
18 changes: 18 additions & 0 deletions Deployment/Ansible/playbooks/general-server.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# ITNOA

- name: Install vim
hosts: workers
become: True
tasks:
- name: Ansible Upgrade all Packages
register: updatesys
apt:
upgrade: full
state: latest
update_cache: yes
cache_valid_time: 3600
- name: Display the last line of the previous task to show that the cache was updated
debug:
msg: "{{updatesys.stdout}}"
- name: install vim
apt: name=vim state=latest
13 changes: 13 additions & 0 deletions Deployment/Ansible/playbooks/hosts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# ITNOA

[workers]
host1 ansible_host=172.22.64.3
host2 ansible_host=172.22.64.4
host3 ansible_host=172.22.64.5
host4 ansible_host=172.22.64.6

[all:vars]
ansible_connection=ssh
ansible_user=ssoroosh
ansible_ssh_pass=a
ansible_become_pass=a
32 changes: 32 additions & 0 deletions Deployment/Powershell/prepare-windows.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# ITNOA

Install-Module 7Zip4PowerShell -Scope CurrentUser -Force -Verbose

# Install choco
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

# Install Ubuntu On Windows
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

Invoke-WebRequest -Uri https://aka.ms/wslubuntu2004 -OutFile ~/Ubuntu.zip -UseBasicParsing

# OpenSSH
# Install the OpenSSH Client
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0

# Install the OpenSSH Server
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0

# Start the sshd service
Start-Service sshd

# OPTIONAL but recommended:
Set-Service -Name sshd -StartupType 'Automatic'

# Confirm the Firewall rule is configured. It should be created automatically by setup. Run the following to verify
if (!(Get-NetFirewallRule -Name "OpenSSH-Server-In-TCP" -ErrorAction SilentlyContinue | Select-Object Name, Enabled)) {
Write-Output "Firewall Rule 'OpenSSH-Server-In-TCP' does not exist, creating it..."
New-NetFirewallRule -Name 'OpenSSH-Server-In-TCP' -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
} else {
Write-Output "Firewall rule 'OpenSSH-Server-In-TCP' has been created and exists."
}

0 comments on commit 653458f

Please sign in to comment.