diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c996e50 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.key diff --git a/README.md b/README.md index c1d2696..0d34931 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,12 @@ -# ansible-lab +# Ansible collection for Windows +# Requirements +testrun.yml requires powershell 7 + +# Install plugins +Install amazon.aws plugin: ansible-galaxy collection install amazon.aws +Install ssm plygin: ansible-galaxy collection install community.aws +Install win_shell plugin: ansible-galaxy collection install ansible.windows + +# Example +ansible-playbook playbooks/testrun.yml diff --git a/ansible.cfg b/ansible.cfg new file mode 100644 index 0000000..cc2fb66 --- /dev/null +++ b/ansible.cfg @@ -0,0 +1,4 @@ +[defaults] +inventory = ./aws_ec2.yml +enable_plugins = aws_ec2 +host_key_checking = False diff --git a/aws_ec2.yml b/aws_ec2.yml new file mode 100644 index 0000000..c3ab34f --- /dev/null +++ b/aws_ec2.yml @@ -0,0 +1,13 @@ +plugin: amazon.aws.aws_ec2 +regions: + - ap-east-1 + +filters: + instance-state-name: running + +hostnames: + - name: 'instance-id' + +#compose: +# ansible_host: instance_id +# ansible_connection: 'community.aws.aws_ssm' diff --git a/playbooks/testrun.yml b/playbooks/testrun.yml new file mode 100644 index 0000000..8f4c2dc --- /dev/null +++ b/playbooks/testrun.yml @@ -0,0 +1,26 @@ +--- +- name: First windows playbook + hosts: all + gather_facts: no + collections: + - ansible.windows + + tasks: + - name: Get powershell version, requires powershell 7 + ansible.windows.win_powershell: + script: | + $PSVersionTable.PSVersion.ToString() + executable: pwsh.exe + register: win_out + vars: + ansible_connection: amazon.aws.aws_ssm + ansible_aws_ssm_bucket_name: rosm-ansible-040216112220 + ansible_aws_ssm_region: ap-east-1 + ansible_aws_ssm_retries: 2 + ansible_aws_ssm_timeout: 20 + ansible_shell_type: powershell + #ansible_shell_executable: pwsh.exe + + - name: Show output + debug: + msg: "{{ win_out.output[0] }}"