From bd95a6df37c5ef416cd0a9d30b3f2bf89b293b40 Mon Sep 17 00:00:00 2001 From: James Tombleson Date: Sat, 6 Apr 2019 11:28:01 -0700 Subject: [PATCH] PowerShell can be installed on Linux --- .gitignore | 1 + README.md | 34 +++++++++++++++++++++- hosts | 5 ++++ playbook/linux/InstallDocker.yml | 6 ++++ playbook/linux/InstallPowerShellCore.yml | 36 ++++++++++++++++++++++++ playbook/linux/UpdatePackages.yml | 22 +++++++++++++++ 6 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 .gitignore create mode 100644 hosts create mode 100644 playbook/linux/InstallDocker.yml create mode 100644 playbook/linux/InstallPowerShellCore.yml create mode 100644 playbook/linux/UpdatePackages.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2d50efe --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.retry \ No newline at end of file diff --git a/README.md b/README.md index ab8b4fd..27c2995 100644 --- a/README.md +++ b/README.md @@ -1 +1,33 @@ -# Ansible \ No newline at end of file +# Ansible + +First things first, install ansible + +```bash +sudo apt-get install ansible +``` + +## Configuration + +[doc](https://docs.ansible.com/ansible/latest/reference_appendices/config.html#ansible-configuration-settings-locations) + +The configuration file +Changes can be made and used in a configuration file which will be searched for in the following order: + +ANSIBLE_CONFIG (environment variable if set) +ansible.cfg (in the current directory) +~/.ansible.cfg (in the home directory) +/etc/ansible/ansible.cfg + +## Inventory + +The default location for inventory should be placed in /etc/ansible/hosts. But you can always overwrite what inventory file is used with the -i flag + + + +## Cheat Sheet + +Quick notes for ansible via cmd + +```bash +ansible -i \inb +``` \ No newline at end of file diff --git a/hosts b/hosts new file mode 100644 index 0000000..6aad057 --- /dev/null +++ b/hosts @@ -0,0 +1,5 @@ +[linux] +192.168.0.60 ansible_connection=ssh ansible_user=miharu + +[windows] +192.168.0.2 ansible_connection=winrm ansible_user=ansible diff --git a/playbook/linux/InstallDocker.yml b/playbook/linux/InstallDocker.yml new file mode 100644 index 0000000..c86fe13 --- /dev/null +++ b/playbook/linux/InstallDocker.yml @@ -0,0 +1,6 @@ + +- name: Install Docker + hosts: linux + + tasks: + \ No newline at end of file diff --git a/playbook/linux/InstallPowerShellCore.yml b/playbook/linux/InstallPowerShellCore.yml new file mode 100644 index 0000000..7b1699e --- /dev/null +++ b/playbook/linux/InstallPowerShellCore.yml @@ -0,0 +1,36 @@ + +- name: Install PowerShell Core + hosts: linux + #debugger: always + + tasks: + - name: Check if PowerShell is installed + #register: command_result + failed_when: "'Failed' PowerShell is already installed." + apt: + name: powershell + state: absent + + - name: Install Microsoft GPG Key + get_url: + url: https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb + dest: /tmp/ + + - name: Register GPG Key + become: true + become_method: sudo + apt: deb="/tmp/packages-microsoft-prod.deb" + #command: dpkg -i ~/packages-microsoft-prod.deb + + - name: Update repos and Install PowerShell Core + become: true + become_method: sudo + apt: + name: powershell + update_cache: yes + state: present + + - name: Remove Extra files + file: + state: absent + path: /tmp/packages-microsoft-prod.deb diff --git a/playbook/linux/UpdatePackages.yml b/playbook/linux/UpdatePackages.yml new file mode 100644 index 0000000..b79f661 --- /dev/null +++ b/playbook/linux/UpdatePackages.yml @@ -0,0 +1,22 @@ + +- name: Update Repos + hosts: linux + + tasks: + - name: Update Repos + become: true + become_method: sudo + apt: + update_cache: yes + + - name: Upgrade Packages + become: true + become_method: sudo + apt: + upgrade: yes + + - name: Remove unused packages + become: true + become_method: sudo + apt: + autoremove: yes \ No newline at end of file