Browse Source

Add changed_when to AWS API

tags/0.0.2^2
Julien Cabillot 2 years ago
parent
commit
4f0bd2f60d
No known key found for this signature in database GPG Key ID: EF8F0EB0565E282F
8 changed files with 143 additions and 23 deletions
  1. +1
    -0
      Jenkinsfile
  2. +1
    -1
      README.md
  3. +103
    -0
      kitchen.yml
  4. +22
    -20
      tasks/main.yml
  5. +8
    -0
      test/integration/default/default.rb
  6. +6
    -0
      tests/test.yml
  7. +1
    -1
      vars/Debian.yml
  8. +1
    -1
      vars/RedHat.yml

+ 1
- 0
Jenkinsfile View File

@@ -0,0 +1 @@
fxPlaybook()

+ 1
- 1
README.md View File

@@ -1,7 +1,7 @@
ansible-role-aws-efs
====================

Mount EFS volume for CentOS / RHEL / Debian.
Mount EFS volume for CentOS / RHEL / Amazon Linux 2 / Debian

Requirements
------------


+ 103
- 0
kitchen.yml View File

@@ -0,0 +1,103 @@
---

driver:
name: "ec2"
associate_public_ip: true
aws_ssh_key_id: "fxlab_jenkins"
interface: "public"
region: "us-east-1"
require_chef_omnibus: false
subnet_id: "subnet-cd28dca9"
iam_profile_name: "AmazonEC2ReadOnlyAccess"

transport:
name: "ssh"
ssh_key: "/id_rsa.pem"
username: "ec2-user"
connection_retries: 5
connection_retry_sleep: 30
max_wait_until_ready: 300
# BUG Related to https://github.com/test-kitchen/test-kitchen/pull/1047
max_ssh_sessions: 2

provisioner:
name: "ansible_playbook"
hosts: "all"
ansible_connection: "local"
ansible_verbose: false
ansible_verbosity: 2
require_pip: true
ansible_version: "2.7.10"
idempotency_test: true
require_chef_for_busser: false
require_ruby_for_busser: false
role_name: "ansible-role-aws-efs"
roles_path: "."

platforms:
- name: "rhel-7"
driver:
instance_type: "t3.small"
tags:
Name: "tk-ansible-role-aws-efs"
kitchen: "true"
packer: "true"
- name: "centos-7"
driver:
image_search:
name: "CentOS Linux 7*"
owner-id: "679593333241"
product-code: "aw0evgkw8e5c1q413zgy5pjce"
instance_type: "t3.small"
tags:
Name: "tk-ansible-role-aws-efs"
kitchen: "true"
packer: "true"
transport:
username: "centos"
- name: "amazon2-2019"
driver:
instance_type: "t3.small"
tags:
Name: "tk-ansible-role-aws-efs"
kitchen: "true"
packer: "true"

verifier:
name: inspec
sudo: true
reporter:
- cli
- junit:%{platform}_%{suite}_inspec.xml

suites:
- name: "rhel"
includes:
- "rhel-7"
provisioner:
name: "ansible_playbook"
playbook: "tests/test.yml"
verifier:
inspec_tests:
- name: local
path: test/integration/default/
- name: "centos"
includes:
- "centos-7"
provisioner:
name: "ansible_playbook"
playbook: "tests/test.yml"
verifier:
inspec_tests:
- name: local
path: test/integration/default/
- name: "amazon"
includes:
- "amazon2-2019"
provisioner:
name: "ansible_playbook"
playbook: "tests/test.yml"
verifier:
inspec_tests:
- name: local
path: test/integration/default/

+ 22
- 20
tasks/main.yml View File

@@ -1,32 +1,34 @@
---
- name: Include OS-specific variables

- name: 'Include OS-specific variables'
include_vars: "{{ ansible_os_family }}.yml"

- name: Ensure NFS is installed
package:
name: "{{ nfs_package }}"
state: present
- name: 'Ensure NFS is installed'
package:
name: "{{ nfs_package }}"
state: 'present'

- name: Ensure mount directories exist
file:
path: "{{ item.path }}"
state: directory
mode: "{{ item.mode }}"
- name: 'Ensure mount directories exist'
file:
path: "{{ item.path }}"
state: 'directory'
mode: "{{ item.mode }}"
owner: "{{ item.owner }}"
group: "{{ item.group }}"
loop: "{{ aws_efs_paths }}"

- name: Get current Availibity Zone from AWS
- name: 'Get current Availibity Zone from AWS'
uri:
url: http://169.254.169.254/latest/meta-data/placement/availability-zone
url: 'http://169.254.169.254/latest/meta-data/placement/availability-zone'
return_content: yes
register: availability_zone
changed_when: False
register: 'availability_zone'

- name: Ensure EFS volume is mounted
mount:
name: "{{ item.path }}"
src: "{{ availability_zone.content }}.{{ item.filesystem_id }}.efs.{{ item.region }}.amazonaws.com:/"
fstype: nfs4
opts: nfsvers=4.1
state: mounted
- name: 'Ensure EFS volume is mounted'
mount:
name: "{{ item.path }}"
src: "{{ availability_zone.content }}.{{ item.filesystem_id }}.efs.{{ item.region }}.amazonaws.com:/"
fstype: 'nfs4'
opts: 'nfsvers=4.1'
state: 'mounted'
loop: "{{ aws_efs_paths }}"

+ 8
- 0
test/integration/default/default.rb View File

@@ -0,0 +1,8 @@
control "ansible-role-aws-efs - #{os.name} #{os.release} - 01" do
impact 1.0
title 'Ansible role aws efs'

describe package('nfs-utils') do
it { should be_installed }
end
end

+ 6
- 0
tests/test.yml View File

@@ -0,0 +1,6 @@
---
- hosts: 'localhost'
become: yes
remote_user: 'root'
roles:
- role: 'ansible-role-docker-aws-efs'

+ 1
- 1
vars/Debian.yml View File

@@ -1,2 +1,2 @@
---
nfs_package: nfs-common
nfs_package: 'nfs-common'

+ 1
- 1
vars/RedHat.yml View File

@@ -1,2 +1,2 @@
---
nfs_package: nfs-utils
nfs_package: 'nfs-utils'

Loading…
Cancel
Save