├── roles └── .gitkeep ├── collections └── .gitkeep ├── key.txt ├── group_vars └── dev │ └── vars.yml ├── README.md ├── playbooks ├── vars │ ├── 06-vars.yaml │ ├── users.yaml │ ├── 18-users.yaml │ ├── 31-users.yaml │ └── 40-users.yaml ├── 09-gather-facts-validation.yaml ├── 11-magic-variables.yaml ├── 01-first-playbook.md ├── 10-turnoff-gather-facts.yaml ├── 05-host-scope.yaml ├── 32-copy-vs-template.yaml ├── 06-play-scope.yaml ├── 33-jinja2-if-else-block.yaml ├── 40-ansible-vault-play.yaml ├── 12-target-group-from-inventory.yaml ├── 51-install-docker.yaml ├── 50-jenkins-install-by-roles.yaml ├── 04-debug-variable-value.yaml ├── 02-deploy-static-website.md ├── 19-delegate-to.yaml ├── 52-kubernetes.yaml ├── templates │ ├── 34-template-with-loop.conf │ ├── hosts.j2 │ └── 33-specs.conf ├── 60-collection-in-playbook.yaml ├── 32-file.conf ├── tasks │ └── nginx-install.yaml ├── 04b-variable-nested-object.yaml ├── 23-POC-before-handlers.yaml ├── 24-POC-handlers.yaml ├── 14-magic-variables-handson.yaml ├── 08-registered-variables.yaml ├── 22-after-using-import-tasks.yaml ├── 34-jinja2-for-loop.yaml ├── 01-first-playbook.yaml ├── 02-deploy-static-website.yaml ├── 03-using-variables.yaml ├── 13-vars-host-scoped.yaml ├── 21-before-use-import-tasks.yaml ├── 07-real-case-for-cicd-pipelines.yaml ├── 16-with-loop.yaml ├── 15-before-loops.yaml ├── 17-when-conditional-task.yaml └── 30-jinja2-filters.yaml ├── multi-files-inventory ├── project1 └── project2 ├── adhoc └── prod.env ├── host_vars └── dev1 │ └── vars.yml ├── ansible.cfg ├── .gitignore ├── inventory-demo-group-of-groups └── hosts ├── cleaners ├── clean-01-first-playbook.yaml └── clean-02-deploy-static-website.yaml ├── k8s.inventory ├── requirements.yaml ├── yaml-course ├── example.yaml ├── playbook-structure.yaml └── exercise.json ├── inventory-demo-dynamic └── script.js ├── inventory ├── inventory-demo-dynamic-aws └── ec2.js └── facts /roles/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /collections/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /key.txt: -------------------------------------------------------------------------------- 1 | MyMasterPassword#423$!2e12e -------------------------------------------------------------------------------- /group_vars/dev/vars.yml: -------------------------------------------------------------------------------- 1 | --- 2 | git_branch: ansible-course -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ansible-course 2 | 3 | # LICENSE 4 | 5 | LGPL v3 6 | -------------------------------------------------------------------------------- /playbooks/vars/06-vars.yaml: -------------------------------------------------------------------------------- 1 | webserver: nginx 2 | webserver_root_dir: /var/www/html -------------------------------------------------------------------------------- /multi-files-inventory/project1: -------------------------------------------------------------------------------- 1 | server1 2 | server2 3 | 4 | [servers] 5 | server1 6 | server2 -------------------------------------------------------------------------------- /multi-files-inventory/project2: -------------------------------------------------------------------------------- 1 | instance1 2 | instance2 3 | 4 | [instances] 5 | instance1 6 | instance2 -------------------------------------------------------------------------------- /playbooks/vars/users.yaml: -------------------------------------------------------------------------------- 1 | assignment_user_name: ahmed 2 | assignment_user_id: 4000 3 | assignment_group: developers -------------------------------------------------------------------------------- /adhoc/prod.env: -------------------------------------------------------------------------------- 1 | REACT_APP_GOOGLE_ANALYTICS_ID=gh4343 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /host_vars/dev1/vars.yml: -------------------------------------------------------------------------------- 1 | --- 2 | ansible_host: 3.22.184.68 3 | ansible_ssh_user: ubuntu 4 | ansible_private_key_file: ohio-key.pem -------------------------------------------------------------------------------- /ansible.cfg: -------------------------------------------------------------------------------- 1 | [defaults] 2 | INVENTORY = ./inventory 3 | vault_password_file = ./key.txt 4 | roles_path = ./roles 5 | COLLECTIONS_PATHS = ./collections -------------------------------------------------------------------------------- /playbooks/vars/18-users.yaml: -------------------------------------------------------------------------------- 1 | assignment_users: 2 | - name: ahmed 3 | role: developer 4 | - name: mouath 5 | role: developer 6 | - name: ali 7 | role: ops 8 | 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ansibleuser* 2 | *.py 3 | _.yaml 4 | *assign* 5 | *.pem 6 | *.tmp 7 | 8 | roles/* 9 | !roles/.gitkeep 10 | 11 | collections/* 12 | !collections/.gitkeep -------------------------------------------------------------------------------- /playbooks/09-gather-facts-validation.yaml: -------------------------------------------------------------------------------- 1 | - name: play for discover gather facts task 2 | hosts: ec2 3 | tasks: 4 | - name: print ansible_facts 5 | debug: 6 | var: ansible_facts -------------------------------------------------------------------------------- /playbooks/11-magic-variables.yaml: -------------------------------------------------------------------------------- 1 | - name: play for discover magic variables 2 | hosts: ec2 3 | gather_facts: no 4 | tasks: 5 | - name: print inventory_hostname 6 | - name: print hostvars -------------------------------------------------------------------------------- /playbooks/01-first-playbook.md: -------------------------------------------------------------------------------- 1 | # Play Overview 2 | 3 | - create file `/tmp/hello.txt` with some content 4 | - create another `/tmp/hi.txt` with some content. 5 | - Put two files into archive, ZIP file format -------------------------------------------------------------------------------- /playbooks/10-turnoff-gather-facts.yaml: -------------------------------------------------------------------------------- 1 | - name: play for turn-off gather facts task 2 | hosts: ec2 3 | gather_facts: no 4 | tasks: 5 | - name: print ansible_facts 6 | debug: 7 | var: ansible_facts -------------------------------------------------------------------------------- /playbooks/05-host-scope.yaml: -------------------------------------------------------------------------------- 1 | - hosts: ec2 2 | become: yes 3 | vars: 4 | webserver_root_dir: /var/www/html 5 | tasks: 6 | - name: debug 7 | debug: 8 | msg: "the value of webserver is {{ webserver }}" 9 | -------------------------------------------------------------------------------- /playbooks/32-copy-vs-template.yaml: -------------------------------------------------------------------------------- 1 | - name: play to generate SPECS report 2 | hosts: container 3 | tasks: 4 | - name: report is generated 5 | template: 6 | src: ./32-file.conf 7 | dest: /tmp/specs.conf 8 | -------------------------------------------------------------------------------- /playbooks/06-play-scope.yaml: -------------------------------------------------------------------------------- 1 | - hosts: ec2 2 | become: yes 3 | vars_files: 4 | - vars/06-vars.yaml 5 | 6 | tasks: 7 | - name: debug 8 | debug: 9 | msg: "the value of webserver is {{ webserver }}" 10 | -------------------------------------------------------------------------------- /playbooks/33-jinja2-if-else-block.yaml: -------------------------------------------------------------------------------- 1 | - name: play to generate SPECS report 2 | hosts: container 3 | tasks: 4 | - name: report is generated 5 | template: 6 | src: 33-specs.conf 7 | dest: /tmp/specs.conf 8 | -------------------------------------------------------------------------------- /playbooks/40-ansible-vault-play.yaml: -------------------------------------------------------------------------------- 1 | - name: play use encrypted vars 2 | hosts: localhost 3 | vars_files: 4 | - vars/40-users.yaml 5 | tasks: 6 | - name: encrypted variable is printed 7 | debug: 8 | var: my_users -------------------------------------------------------------------------------- /playbooks/12-target-group-from-inventory.yaml: -------------------------------------------------------------------------------- 1 | - name: play - target group from large inventory 2 | hosts: prod 3 | become: yes 4 | tasks: 5 | - name: nginx is installed 6 | package: 7 | name: nginx 8 | state: present -------------------------------------------------------------------------------- /playbooks/51-install-docker.yaml: -------------------------------------------------------------------------------- 1 | - hosts: prod1,prod2,dev1 2 | become: yes 3 | tasks: 4 | - name: docker is installed 5 | import_role: 6 | name: geerlingguy.docker 7 | vars: 8 | docker_users: 9 | - "{{ ansible_ssh_user }}" -------------------------------------------------------------------------------- /playbooks/vars/31-users.yaml: -------------------------------------------------------------------------------- 1 | assignment_users: 2 | - name: ahmed 3 | password: ahmed123 4 | role: developer 5 | - name: mouath 6 | password: mouath123 7 | role: developer 8 | - name: ali 9 | password: aliali123 10 | role: ops 11 | -------------------------------------------------------------------------------- /playbooks/50-jenkins-install-by-roles.yaml: -------------------------------------------------------------------------------- 1 | - hosts: dev1 2 | become: true 3 | vars: 4 | # jenkins_hostname: jenkins.example.com 5 | java_packages: 6 | - openjdk-8-jdk 7 | roles: 8 | - role: geerlingguy.java 9 | - role: geerlingguy.jenkins -------------------------------------------------------------------------------- /inventory-demo-group-of-groups/hosts: -------------------------------------------------------------------------------- 1 | server1 2 | server2 3 | server3 4 | server4 5 | server5 6 | 7 | [app] 8 | server1 9 | server2 10 | 11 | [mysql] 12 | server3 13 | server4 14 | 15 | [postgres] 16 | server5 17 | 18 | [db:children] 19 | mysql 20 | postgres -------------------------------------------------------------------------------- /playbooks/04-debug-variable-value.yaml: -------------------------------------------------------------------------------- 1 | - hosts: ec2 2 | become: yes 3 | vars: 4 | webserver: nginx 5 | webserver_root_dir: /var/www/html 6 | tasks: 7 | - name: debug 8 | debug: 9 | msg: "the value of webserver is {{ webserver }}" 10 | 11 | -------------------------------------------------------------------------------- /playbooks/02-deploy-static-website.md: -------------------------------------------------------------------------------- 1 | # Play Overview 2 | 3 | - Make sure the WebServer is installed & running on port 80 4 | - Deploy the Website from this source code : 5 | 6 | * https://github.com/abdennour/example-static-website/tree/ansible-course 7 | * branch : ansible-course -------------------------------------------------------------------------------- /cleaners/clean-01-first-playbook.yaml: -------------------------------------------------------------------------------- 1 | - name: play for file management 2 | hosts: ec2 3 | tasks: 4 | - name: all files are deleted 5 | file: 6 | path: "{{ item }}" 7 | state: absent 8 | loop: 9 | - /tmp/hello.txt 10 | - /tmp/hi.txt 11 | - /tmp/hh.zip -------------------------------------------------------------------------------- /playbooks/19-delegate-to.yaml: -------------------------------------------------------------------------------- 1 | - name: play to show how to use delegate_to 2 | hosts: dev1 3 | tasks: 4 | - name: string is copied into a file 5 | copy: 6 | content: This is a message while targeting {{ inventory_hostname }} 7 | dest: /tmp/message.txt 8 | delegate_to: localhost -------------------------------------------------------------------------------- /playbooks/52-kubernetes.yaml: -------------------------------------------------------------------------------- 1 | - name: play kubernets is up 2 | hosts: cluster 3 | become: yes 4 | tasks: 5 | - name: docker role 6 | import_role: 7 | name: geerlingguy.docker 8 | - name: kubernetes role 9 | import_role: 10 | name: geerlingguy.kubernetes 11 | -------------------------------------------------------------------------------- /playbooks/templates/34-template-with-loop.conf: -------------------------------------------------------------------------------- 1 | ==== Print app_pages ===== 2 | 3 | {% for page in app_pages %} 4 | {{ page }}.html is a web page 5 | {% endfor %} 6 | 7 | ==== Print app_users ==== 8 | {% for u in app_users %} 9 | {{ u.name | capitalize }} is {{ u.role }} 10 | {% endfor %} -------------------------------------------------------------------------------- /playbooks/60-collection-in-playbook.yaml: -------------------------------------------------------------------------------- 1 | - name: play usage collections 2 | hosts: container 3 | collections: 4 | - newswangerd.collection_demo 5 | tasks: 6 | - name: module usage from collection 7 | real_facts: 8 | name: Abdennour 9 | - name: role usage from collection 10 | import_role: 11 | name: factoid -------------------------------------------------------------------------------- /k8s.inventory: -------------------------------------------------------------------------------- 1 | master1 ansible_host=3.12.97.206 kubernetes_role=master 2 | node1 ansible_host=3.20.167.21 kubernetes_role=node 3 | node2 ansible_host=3.22.184.68 kubernetes_role=node 4 | 5 | [cluster] 6 | master1 7 | node1 8 | node2 9 | 10 | [cluster:vars] 11 | ansible_ssh_user=ec2-user 12 | ansible_private_key_file=ohio-key.pem 13 | 14 | -------------------------------------------------------------------------------- /playbooks/32-file.conf: -------------------------------------------------------------------------------- 1 | Distribution : {{ ansible_facts.distribution }} 2 | Distribution Release : {{ ansible_facts.distribution_release }} 3 | Distribution Version : {{ ansible_facts.distribution_version }} 4 | Nbre CPU core : {{ ansible_facts.processor_cores }} cores 5 | Total Memory : {{ ansible_facts.memtotal_mb }} mb 6 | -------------------------------------------------------------------------------- /playbooks/tasks/nginx-install.yaml: -------------------------------------------------------------------------------- 1 | - name: webserver is installed 2 | package: 3 | name: "{{ webserver }}" 4 | state: present 5 | - name: webserver is up 6 | service: 7 | name: "{{ webserver }}" 8 | state: started 9 | - name: webserver root directory exists 10 | file: 11 | path: "{{ webserver_root_dir }}" 12 | state: directory -------------------------------------------------------------------------------- /playbooks/04b-variable-nested-object.yaml: -------------------------------------------------------------------------------- 1 | - hosts: ec2 2 | become: yes 3 | vars: 4 | webserver: 5 | type: nginx 6 | root_dir: /var/www/html 7 | # webserver_type: nginx 8 | # webserver_root_dir: /var/www/html 9 | tasks: 10 | - name: debug 11 | debug: 12 | msg: "the value of webserver is {{ webserver['type'] }} .. dir {{ webserver.root_dir }}" 13 | 14 | -------------------------------------------------------------------------------- /playbooks/23-POC-before-handlers.yaml: -------------------------------------------------------------------------------- 1 | - name: play illustrates the Slide of handlers 2 | hosts: somehost 3 | tasks: 4 | - name: t1 5 | module-a: 6 | attr1: val1 7 | - name: t2 8 | module-b: 9 | attr1: val1 10 | # run t3 only if t2 CHANGED 11 | - name: t3 12 | module-c: 13 | attr1: val1 14 | - name: t4 15 | module-d: 16 | attr1: val1 17 | -------------------------------------------------------------------------------- /requirements.yaml: -------------------------------------------------------------------------------- 1 | # - src: 2 | # name: 3 | # version: 4 | roles: 5 | - src: geerlingguy.java 6 | name: geerlingguy.java 7 | 8 | - src: geerlingguy.jenkins 9 | name: geerlingguy.jenkins 10 | 11 | - src: geerlingguy.docker 12 | name: geerlingguy.docker 13 | - src: geerlingguy.kubernetes 14 | name: geerlingguy.kubernetes 15 | 16 | collections: 17 | - newswangerd.collection_demo -------------------------------------------------------------------------------- /cleaners/clean-02-deploy-static-website.yaml: -------------------------------------------------------------------------------- 1 | - hosts: ec2 2 | become: yes 3 | tasks: 4 | - name: webserver is down 5 | service: 6 | name: nginx 7 | state: stopped 8 | - name: webserver is removed 9 | package: 10 | name: nginx 11 | state: absent 12 | - name: webserver root dir is absent 13 | file: 14 | path: /var/www/html 15 | state: absent 16 | -------------------------------------------------------------------------------- /playbooks/templates/hosts.j2: -------------------------------------------------------------------------------- 1 | 127.0.0.1 localhost 2 | 3 | # The following lnes are desirable for IPv6 capable hosts 4 | ::1 ip6-localhost ip6-loopback 5 | fe00::0 ip6-localnet 6 | ff00::0 ip6-mcastprefix 7 | ff02::1 ip6-allnodes 8 | ff02::2 ip6-allrouters 9 | ff02::3 ip6-allhosts 10 | 11 | {% for host in groups['all'] %} 12 | {{ hostvars[host]['ansible_default_ipv4']['address'] }} {{ host }} 13 | {% endfor %} -------------------------------------------------------------------------------- /playbooks/24-POC-handlers.yaml: -------------------------------------------------------------------------------- 1 | - name: play illustrates the Slide of handlers 2 | hosts: somehost 3 | tasks: 4 | - name: t1 5 | module-a: 6 | attr1: val1 7 | - name: t2 8 | module-b: 9 | attr1: val1 10 | notify: t3 11 | # run t3 only if t2 CHANGED 12 | - name: t4 13 | module-d: 14 | attr1: val1 15 | handlers: 16 | - name: t3 17 | module-c: 18 | attr1: val1 -------------------------------------------------------------------------------- /playbooks/14-magic-variables-handson.yaml: -------------------------------------------------------------------------------- 1 | - name: play for discover magic variables 2 | hosts: dev,prod 3 | gather_facts: no 4 | tasks: 5 | - name: print inventory_hostname 6 | debug: 7 | var: inventory_hostname 8 | - name: print hostvars 9 | debug: 10 | var: hostvars 11 | - name: print group_names 12 | debug: 13 | var: group_names 14 | - name: print groups 15 | debug: 16 | var: groups -------------------------------------------------------------------------------- /playbooks/08-registered-variables.yaml: -------------------------------------------------------------------------------- 1 | - hosts: ec2 2 | become: yes 3 | tasks: 4 | - name: webserver is installed 5 | package: 6 | name: nginx 7 | state: present 8 | register: nginx_install_output 9 | - name: print in terminal 10 | debug: 11 | var: nginx_install_output 12 | 13 | - name: copy the output 14 | copy: 15 | content: "{{ nginx_install_output }}" 16 | dest: /tmp/task1-ouput 17 | 18 | -------------------------------------------------------------------------------- /yaml-course/example.yaml: -------------------------------------------------------------------------------- 1 | event: DevOps Days 2 | date: 2018-12-03 10:00GMT+3 3 | location: 4 | building: IT Stars 5 | address: 6 | lines: | 7 | 7173 Floor 2 8 | Street Randa 9 | city: Tunis 10 | postal: 12233 11 | # List of topics 12 | topics: 13 | - name: Reliability in IT 14 | minutes: 20 15 | speaker: Abdennour Toumi 16 | - name: K8S Hands-on 17 | minutes: 40 18 | speaker: Firas Abid 19 | 20 | -------------------------------------------------------------------------------- /playbooks/22-after-using-import-tasks.yaml: -------------------------------------------------------------------------------- 1 | 2 | - hosts: dev 3 | become: yes 4 | vars: 5 | webserver: nginx 6 | webserver_root_dir: /var/www/html 7 | tasks: 8 | - name: import nginx install tasks 9 | import_tasks: tasks/nginx-install.yaml 10 | - name: static website is deployed 11 | uri: 12 | url: https://raw.githubusercontent.com/abdennour/example-static-website/{{ git_branch }}/index.html 13 | dest: "{{ webserver_root_dir }}" # /usr/share/nginx/html 14 | -------------------------------------------------------------------------------- /yaml-course/playbook-structure.yaml: -------------------------------------------------------------------------------- 1 | - name: Play 1 - App Deployment 2 | hosts: all 3 | tasks: 4 | - name: directory exist 5 | file: 6 | path: /tomcat/webapps 7 | state: directory 8 | - name: file is copied 9 | copy: 10 | src: target/app.war 11 | dest: /tomcat/webapps/app.war 12 | - name: Play 2 - DB Deployment 13 | hosts: db 14 | tasks: 15 | - name: DB engine is installed 16 | service: 17 | name: mysql 18 | state: latest 19 | 20 | -------------------------------------------------------------------------------- /playbooks/templates/33-specs.conf: -------------------------------------------------------------------------------- 1 | Distribution : {{ ansible_facts.distribution }} 2 | Distribution Release : {{ ansible_facts.distribution_release }} 3 | Distribution Version : {{ ansible_facts.distribution_version }} 4 | Nbre CPU core : {{ ansible_facts.processor_cores }} cores 5 | Total Memory : {{ ansible_facts.memtotal_mb }} mb 6 | 7 | 8 | {% if ansible_facts.memtotal_mb < 4000 %} 9 | The memory size is small 10 | {% else %} 11 | The memory size is OK 12 | {% endif %} -------------------------------------------------------------------------------- /playbooks/vars/40-users.yaml: -------------------------------------------------------------------------------- 1 | $ANSIBLE_VAULT;1.1;AES256 2 | 65396530316537653834373639323333333037643565353135373365343561326163303337643938 3 | 3463353666363231343030326336306666326563363566340a386434366139663932353536336131 4 | 38396564626636366237383634383836346136623333303633363065373566373032386337613461 5 | 6135383962343035630a633162626566653130346262633436636635383062333134386336656163 6 | 38373638343864373066323664373735343962333061363866313531366461656362313836666539 7 | 6562303362613530653136373335333234373339313934643139 8 | -------------------------------------------------------------------------------- /playbooks/34-jinja2-for-loop.yaml: -------------------------------------------------------------------------------- 1 | - name: play to generate SPECS report 2 | hosts: container 3 | vars: 4 | app_pages: 5 | - home 6 | - login 7 | - logout 8 | app_users: 9 | - name: ahmed 10 | role: developer 11 | - name: mouath 12 | role: developer 13 | - name: ali 14 | role: ops 15 | - name: omar 16 | role: ops 17 | 18 | tasks: 19 | - name: report is generated 20 | template: 21 | src: 34-template-with-loop.conf 22 | dest: /tmp/app-report.conf 23 | -------------------------------------------------------------------------------- /playbooks/01-first-playbook.yaml: -------------------------------------------------------------------------------- 1 | - name: play for file management 2 | hosts: ec2 3 | tasks: 4 | # create file `/tmp/hello.txt` with some content 5 | - name: hello file is copied 6 | copy: 7 | content: "Hello here" 8 | dest: /tmp/hello.txt 9 | - name: hi file is copied 10 | copy: 11 | content: "Hi here" 12 | dest: /tmp/hi.txt 13 | - name: archive hh is created 14 | archive: 15 | path: 16 | - /tmp/hello.txt 17 | - /tmp/hi.txt 18 | dest: /tmp/hh.zip 19 | format: zip -------------------------------------------------------------------------------- /yaml-course/exercise.json: -------------------------------------------------------------------------------- 1 | { 2 | "course": "Amazon EKS Course", 3 | "instructor": { 4 | "firstname": "Abdennour", 5 | "lastname": "TOUMI", 6 | "website": "http://kubernetes.tn" 7 | }, 8 | "sections": [ 9 | "Introduction", 10 | "Deploy EKS Cluster", 11 | "Deploy App with Helm", 12 | "Conclusion" 13 | ], 14 | "lectures": [ 15 | { 16 | "id": 1, 17 | "name": "introduction", 18 | "minutes": 5 19 | }, 20 | { 21 | "id": 2, 22 | "name": "EKS with Terraform", 23 | "minutes": 14 24 | } 25 | ] 26 | } -------------------------------------------------------------------------------- /playbooks/02-deploy-static-website.yaml: -------------------------------------------------------------------------------- 1 | - hosts: ec2 2 | become: yes 3 | tasks: 4 | - name: webserver is installed 5 | package: 6 | name: nginx 7 | state: present 8 | - name: webserver is up 9 | service: 10 | name: nginx 11 | state: started 12 | 13 | - name: webserver root directory exists 14 | file: 15 | path: /var/www/html 16 | state: directory 17 | - name: static website is deployed 18 | uri: 19 | url: https://raw.githubusercontent.com/abdennour/example-static-website/ansible-course/index.html 20 | dest: /var/www/html # /usr/share/nginx/html 21 | -------------------------------------------------------------------------------- /inventory-demo-dynamic/script.js: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/node 2 | 3 | // --list or --host 4 | const option = process.argv[2] 5 | const hostname = process.argv[3] 6 | 7 | const hosts = { 8 | web1: {ansible_host: '192.168.1.3'}, 9 | web2: {ansible_host: '192.168.1.4'}, 10 | db1: {ansible_host: '192.168.1.5'} 11 | } 12 | 13 | const groups = { 14 | web: ['web1', 'web2'], 15 | db: ['db1'] 16 | } 17 | 18 | 19 | // --host option 20 | if (option === '--host' ) { 21 | console.log(JSON.stringify(hosts[hostname])) 22 | } 23 | // --list option 24 | if (option === '--list' ) { 25 | console.log(JSON.stringify(groups)) 26 | } -------------------------------------------------------------------------------- /inventory: -------------------------------------------------------------------------------- 1 | # ec2 ansible_host=18.222.140.103 ansible_private_key_file=./ansibleuser ansible_ssh_user=ansibleuser webserver=tomcat 2 | # ssh -i ansibleuser ansibleuser@localhost -p 2525 3 | container ansible_host=localhost ansible_private_key_file=./ansibleuser ansible_ssh_user=ansibleuser ansible_ssh_port=2525 4 | ###### 5 | # ssh -i ohio-key.pem ubuntu@3.20.167.21 6 | dev1 7 | prod1 ansible_host=3.12.97.206 8 | prod2 ansible_host=3.20.167.21 9 | 10 | [dev] 11 | dev1 12 | 13 | [prod] 14 | prod1 15 | prod2 16 | 17 | [prod:vars] 18 | ansible_ssh_user=ubuntu 19 | ansible_private_key_file=ohio-key.pem 20 | git_branch=ansible-course-index-v2 -------------------------------------------------------------------------------- /playbooks/03-using-variables.yaml: -------------------------------------------------------------------------------- 1 | - hosts: ec2 2 | become: yes 3 | vars: 4 | webserver: nginx 5 | webserver_root_dir: /var/www/html 6 | tasks: 7 | - name: webserver is installed 8 | package: 9 | name: "{{ webserver }}" 10 | state: present 11 | - name: webserver is up 12 | service: 13 | name: "{{ webserver }}" 14 | state: started 15 | 16 | - name: webserver root directory exists 17 | file: 18 | path: "{{ webserver_root_dir }}" 19 | state: directory 20 | - name: static website is deployed 21 | uri: 22 | url: https://raw.githubusercontent.com/abdennour/example-static-website/ansible-course/index.html 23 | dest: "{{ webserver_root_dir }}" # /usr/share/nginx/html 24 | -------------------------------------------------------------------------------- /playbooks/13-vars-host-scoped.yaml: -------------------------------------------------------------------------------- 1 | 2 | - hosts: prod,dev 3 | become: yes 4 | vars: 5 | webserver: nginx 6 | webserver_root_dir: /var/www/html 7 | tasks: 8 | - name: webserver is installed 9 | package: 10 | name: "{{ webserver }}" 11 | state: present 12 | - name: webserver is up 13 | service: 14 | name: "{{ webserver }}" 15 | state: started 16 | - name: webserver root directory exists 17 | file: 18 | path: "{{ webserver_root_dir }}" 19 | state: directory 20 | - name: static website is deployed 21 | uri: 22 | url: https://raw.githubusercontent.com/abdennour/example-static-website/{{ git_branch }}/index.html 23 | dest: "{{ webserver_root_dir }}" # /usr/share/nginx/html 24 | -------------------------------------------------------------------------------- /playbooks/21-before-use-import-tasks.yaml: -------------------------------------------------------------------------------- 1 | 2 | - hosts: dev 3 | become: yes 4 | vars: 5 | webserver: nginx 6 | webserver_root_dir: /var/www/html 7 | tasks: 8 | - name: webserver is installed 9 | package: 10 | name: "{{ webserver }}" 11 | state: present 12 | - name: webserver is up 13 | service: 14 | name: "{{ webserver }}" 15 | state: started 16 | - name: webserver root directory exists 17 | file: 18 | path: "{{ webserver_root_dir }}" 19 | state: directory 20 | - name: static website is deployed 21 | uri: 22 | url: https://raw.githubusercontent.com/abdennour/example-static-website/{{ git_branch }}/index.html 23 | dest: "{{ webserver_root_dir }}" # /usr/share/nginx/html 24 | -------------------------------------------------------------------------------- /playbooks/07-real-case-for-cicd-pipelines.yaml: -------------------------------------------------------------------------------- 1 | 2 | - hosts: ec2 3 | become: yes 4 | vars: 5 | webserver: nginx 6 | webserver_root_dir: /var/www/html 7 | git_branch: ansible-course 8 | tasks: 9 | - name: webserver is installed 10 | package: 11 | name: "{{ webserver }}" 12 | state: present 13 | - name: webserver is up 14 | service: 15 | name: "{{ webserver }}" 16 | state: started 17 | - name: webserver root directory exists 18 | file: 19 | path: "{{ webserver_root_dir }}" 20 | state: directory 21 | - name: static website is deployed 22 | uri: 23 | url: https://raw.githubusercontent.com/abdennour/example-static-website/{{ git_branch }}/index.html 24 | dest: "{{ webserver_root_dir }}" # /usr/share/nginx/html 25 | -------------------------------------------------------------------------------- /playbooks/16-with-loop.yaml: -------------------------------------------------------------------------------- 1 | 2 | - hosts: prod,dev 3 | become: yes 4 | vars: 5 | webserver: nginx 6 | webserver_root_dir: /var/www/html 7 | tasks: 8 | - name: webserver is installed 9 | package: 10 | name: "{{ webserver }}" 11 | state: present 12 | - name: webserver is up 13 | service: 14 | name: "{{ webserver }}" 15 | state: started 16 | - name: webserver root directory exists 17 | file: 18 | path: "{{ webserver_root_dir }}" 19 | state: directory 20 | - name: static website is deployed 21 | uri: 22 | url: https://raw.githubusercontent.com/abdennour/example-static-website/{{ git_branch }}/{{ item }}.html 23 | dest: "{{ webserver_root_dir }}" # /usr/share/nginx/html 24 | loop: 25 | - index 26 | - about -------------------------------------------------------------------------------- /playbooks/15-before-loops.yaml: -------------------------------------------------------------------------------- 1 | 2 | - hosts: prod,dev 3 | become: yes 4 | vars: 5 | webserver: nginx 6 | webserver_root_dir: /var/www/html 7 | tasks: 8 | - name: webserver is installed 9 | package: 10 | name: "{{ webserver }}" 11 | state: present 12 | - name: webserver is up 13 | service: 14 | name: "{{ webserver }}" 15 | state: started 16 | - name: webserver root directory exists 17 | file: 18 | path: "{{ webserver_root_dir }}" 19 | state: directory 20 | - name: static website is deployed 21 | uri: 22 | url: https://raw.githubusercontent.com/abdennour/example-static-website/{{ git_branch }}/index.html 23 | dest: "{{ webserver_root_dir }}" # /usr/share/nginx/html 24 | - name: about.html is deployed 25 | uri: 26 | url: https://raw.githubusercontent.com/abdennour/example-static-website/{{ git_branch }}/about.html 27 | dest: "{{ webserver_root_dir }}" # /usr/share/nginx/html 28 | -------------------------------------------------------------------------------- /playbooks/17-when-conditional-task.yaml: -------------------------------------------------------------------------------- 1 | 2 | - hosts: prod,dev 3 | become: yes 4 | vars: 5 | webserver: nginx 6 | webserver_root_dir: /var/www/html 7 | tasks: 8 | - name: webserver is installed 9 | package: 10 | name: "{{ webserver }}" 11 | state: present 12 | - name: webserver is up 13 | service: 14 | name: "{{ webserver }}" 15 | state: started 16 | - name: webserver root directory exists 17 | file: 18 | path: "{{ webserver_root_dir }}" 19 | state: directory 20 | - name: static website is deployed 21 | uri: 22 | url: https://raw.githubusercontent.com/abdennour/example-static-website/{{ git_branch }}/index.html 23 | dest: "{{ webserver_root_dir }}" # /usr/share/nginx/html 24 | - name: login page is deployed 25 | uri: 26 | url: https://raw.githubusercontent.com/abdennour/example-static-website/{{ git_branch }}/login.html 27 | dest: "{{ webserver_root_dir }}" # /usr/share/nginx/html 28 | when: git_branch == 'ansible-course' -------------------------------------------------------------------------------- /inventory-demo-dynamic-aws/ec2.js: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/node 2 | const { execSync } = require('child_process'); 3 | const sh = cmd => execSync(cmd, { encoding: 'utf8' }); 4 | // --list or --host 5 | const option = process.argv[2] 6 | const hostname = process.argv[3] 7 | 8 | const result = JSON.parse(sh('aws ec2 describe-instances')) 9 | // console.log(result) 10 | // const hosts = { 11 | // web1: {ansible_host: '192.168.1.3'}, 12 | // web2: {ansible_host: '192.168.1.4'}, 13 | // db1: {ansible_host: '192.168.1.5'} 14 | // } 15 | 16 | // const groups = { 17 | // web: ['web1', 'web2'], 18 | // db: ['db1'] 19 | // } 20 | const hosts = {} 21 | const groups = {} 22 | 23 | result.Reservations.forEach(({ Instances}) => { 24 | Instances.forEach(Instance => { 25 | let inventoryHostname =Instance.Tags.find(({Key, Value}) => Key === 'Name').Value 26 | hosts[inventoryHostname] = { 27 | ansible_host: Instance.PublicIpAddress 28 | } 29 | 30 | if(!groups['all']) { 31 | groups['all']= [] 32 | } 33 | groups['all'] = [...groups['all'], inventoryHostname] 34 | 35 | }) 36 | }) 37 | // --host option 38 | if (option === '--host' ) { 39 | console.log(JSON.stringify(hosts[hostname])) 40 | } 41 | // --list option 42 | if (option === '--list' ) { 43 | console.log(JSON.stringify(groups)) 44 | } -------------------------------------------------------------------------------- /playbooks/30-jinja2-filters.yaml: -------------------------------------------------------------------------------- 1 | # https://jinja.palletsprojects.com/en/2.11.x/templates/#builtin-filters 2 | - name: play with jinja2 filters 3 | hosts: container 4 | gather_facts: no 5 | vars: 6 | git_username: atoumi 7 | git_password: Gfdfd445e 8 | git_repos: ["eks-course", "ansible-course", "react-csv"] 9 | course_lectures_nb: [6, 6, 10, 8, 9] 10 | tasks: 11 | - name: j2 filter - capitalize 12 | debug: 13 | msg: | 14 | original : {{ git_username }} 15 | with filter: {{ git_username | capitalize }} 16 | # require: pip3 install passlib 17 | - name: j2 filter - password_hash('sha512') 18 | debug: 19 | msg: | 20 | original : {{ git_password }} 21 | with filter: {{ git_password | password_hash('sha512') }} 22 | - name: j2 filter - length - nb of repos 23 | debug: 24 | msg: | 25 | original : {{ git_repos }} 26 | with filter: {{ git_repos | length }} 27 | - name: j2 filter - sum - total nb of lectures 28 | debug: 29 | msg: | 30 | original : {{ course_lectures_nb }} 31 | with filter: {{ course_lectures_nb | sum }} 32 | - name: j2 filter - max - max nb of lectures in a section 33 | debug: 34 | msg: | 35 | original : {{ course_lectures_nb }} 36 | with filter: {{ course_lectures_nb | max }} -------------------------------------------------------------------------------- /facts: -------------------------------------------------------------------------------- 1 | 2 | PLAY [play for discover gather facts task] ************************************* 3 | 4 | TASK [Gathering Facts] ********************************************************* 5 | ok: [ec2] 6 | 7 | TASK [print ansible_facts] ***************************************************** 8 | ok: [ec2] => { 9 | "ansible_facts": { 10 | "_facts_gathered": true, 11 | "all_ipv4_addresses": [ 12 | "172.31.41.105" 13 | ], 14 | "all_ipv6_addresses": [ 15 | "fe80::89f:37ff:fe86:330" 16 | ], 17 | "ansible_local": {}, 18 | "apparmor": { 19 | "status": "enabled" 20 | }, 21 | "architecture": "x86_64", 22 | "bios_date": "08/24/2006", 23 | "bios_version": "4.2.amazon", 24 | "cmdline": { 25 | "BOOT_IMAGE": "/boot/vmlinuz-4.15.0-1065-aws", 26 | "console": "ttyS0", 27 | "nvme_core.io_timeout": "4294967295", 28 | "ro": true, 29 | "root": "UUID=c03b791b-60ef-4ae1-82b5-5c9ab6b4d08f" 30 | }, 31 | "date_time": { 32 | "date": "2020-04-25", 33 | "day": "25", 34 | "epoch": "1587805683", 35 | "hour": "09", 36 | "iso8601": "2020-04-25T09:08:03Z", 37 | "iso8601_basic": "20200425T090803113702", 38 | "iso8601_basic_short": "20200425T090803", 39 | "iso8601_micro": "2020-04-25T09:08:03.113798Z", 40 | "minute": "08", 41 | "month": "04", 42 | "second": "03", 43 | "time": "09:08:03", 44 | "tz": "UTC", 45 | "tz_offset": "+0000", 46 | "weekday": "Saturday", 47 | "weekday_number": "6", 48 | "weeknumber": "16", 49 | "year": "2020" 50 | }, 51 | "default_ipv4": { 52 | "address": "172.31.41.105", 53 | "alias": "eth0", 54 | "broadcast": "172.31.47.255", 55 | "gateway": "172.31.32.1", 56 | "interface": "eth0", 57 | "macaddress": "0a:9f:37:86:03:30", 58 | "mtu": 9001, 59 | "netmask": "255.255.240.0", 60 | "network": "172.31.32.0", 61 | "type": "ether" 62 | }, 63 | "default_ipv6": {}, 64 | "device_links": { 65 | "ids": {}, 66 | "labels": { 67 | "xvda1": [ 68 | "cloudimg-rootfs" 69 | ] 70 | }, 71 | "masters": {}, 72 | "uuids": { 73 | "xvda1": [ 74 | "c03b791b-60ef-4ae1-82b5-5c9ab6b4d08f" 75 | ] 76 | } 77 | }, 78 | "devices": { 79 | "loop0": { 80 | "holders": [], 81 | "host": "", 82 | "links": { 83 | "ids": [], 84 | "labels": [], 85 | "masters": [], 86 | "uuids": [] 87 | }, 88 | "model": null, 89 | "partitions": {}, 90 | "removable": "0", 91 | "rotational": "1", 92 | "sas_address": null, 93 | "sas_device_handle": null, 94 | "scheduler_mode": "none", 95 | "sectors": "192064", 96 | "sectorsize": "512", 97 | "size": "93.78 MB", 98 | "support_discard": "4096", 99 | "vendor": null, 100 | "virtual": 1 101 | }, 102 | "loop1": { 103 | "holders": [], 104 | "host": "", 105 | "links": { 106 | "ids": [], 107 | "labels": [], 108 | "masters": [], 109 | "uuids": [] 110 | }, 111 | "model": null, 112 | "partitions": {}, 113 | "removable": "0", 114 | "rotational": "1", 115 | "sas_address": null, 116 | "sas_device_handle": null, 117 | "scheduler_mode": "none", 118 | "sectors": "36832", 119 | "sectorsize": "512", 120 | "size": "17.98 MB", 121 | "support_discard": "4096", 122 | "vendor": null, 123 | "virtual": 1 124 | }, 125 | "loop2": { 126 | "holders": [], 127 | "host": "", 128 | "links": { 129 | "ids": [], 130 | "labels": [], 131 | "masters": [], 132 | "uuids": [] 133 | }, 134 | "model": null, 135 | "partitions": {}, 136 | "removable": "0", 137 | "rotational": "1", 138 | "sas_address": null, 139 | "sas_device_handle": null, 140 | "scheduler_mode": "none", 141 | "sectors": "36824", 142 | "sectorsize": "512", 143 | "size": "17.98 MB", 144 | "support_discard": "4096", 145 | "vendor": null, 146 | "virtual": 1 147 | }, 148 | "loop3": { 149 | "holders": [], 150 | "host": "", 151 | "links": { 152 | "ids": [], 153 | "labels": [], 154 | "masters": [], 155 | "uuids": [] 156 | }, 157 | "model": null, 158 | "partitions": {}, 159 | "removable": "0", 160 | "rotational": "1", 161 | "sas_address": null, 162 | "sas_device_handle": null, 163 | "scheduler_mode": "none", 164 | "sectors": "192352", 165 | "sectorsize": "512", 166 | "size": "93.92 MB", 167 | "support_discard": "4096", 168 | "vendor": null, 169 | "virtual": 1 170 | }, 171 | "loop4": { 172 | "holders": [], 173 | "host": "", 174 | "links": { 175 | "ids": [], 176 | "labels": [], 177 | "masters": [], 178 | "uuids": [] 179 | }, 180 | "model": null, 181 | "partitions": {}, 182 | "removable": "0", 183 | "rotational": "1", 184 | "sas_address": null, 185 | "sas_device_handle": null, 186 | "scheduler_mode": "none", 187 | "sectors": "0", 188 | "sectorsize": "512", 189 | "size": "0.00 Bytes", 190 | "support_discard": "4096", 191 | "vendor": null, 192 | "virtual": 1 193 | }, 194 | "loop5": { 195 | "holders": [], 196 | "host": "", 197 | "links": { 198 | "ids": [], 199 | "labels": [], 200 | "masters": [], 201 | "uuids": [] 202 | }, 203 | "model": null, 204 | "partitions": {}, 205 | "removable": "0", 206 | "rotational": "1", 207 | "sas_address": null, 208 | "sas_device_handle": null, 209 | "scheduler_mode": "none", 210 | "sectors": "0", 211 | "sectorsize": "512", 212 | "size": "0.00 Bytes", 213 | "support_discard": "0", 214 | "vendor": null, 215 | "virtual": 1 216 | }, 217 | "loop6": { 218 | "holders": [], 219 | "host": "", 220 | "links": { 221 | "ids": [], 222 | "labels": [], 223 | "masters": [], 224 | "uuids": [] 225 | }, 226 | "model": null, 227 | "partitions": {}, 228 | "removable": "0", 229 | "rotational": "1", 230 | "sas_address": null, 231 | "sas_device_handle": null, 232 | "scheduler_mode": "none", 233 | "sectors": "0", 234 | "sectorsize": "512", 235 | "size": "0.00 Bytes", 236 | "support_discard": "0", 237 | "vendor": null, 238 | "virtual": 1 239 | }, 240 | "loop7": { 241 | "holders": [], 242 | "host": "", 243 | "links": { 244 | "ids": [], 245 | "labels": [], 246 | "masters": [], 247 | "uuids": [] 248 | }, 249 | "model": null, 250 | "partitions": {}, 251 | "removable": "0", 252 | "rotational": "1", 253 | "sas_address": null, 254 | "sas_device_handle": null, 255 | "scheduler_mode": "none", 256 | "sectors": "0", 257 | "sectorsize": "512", 258 | "size": "0.00 Bytes", 259 | "support_discard": "0", 260 | "vendor": null, 261 | "virtual": 1 262 | }, 263 | "xvda": { 264 | "holders": [], 265 | "host": "", 266 | "links": { 267 | "ids": [], 268 | "labels": [], 269 | "masters": [], 270 | "uuids": [] 271 | }, 272 | "model": null, 273 | "partitions": { 274 | "xvda1": { 275 | "holders": [], 276 | "links": { 277 | "ids": [], 278 | "labels": [ 279 | "cloudimg-rootfs" 280 | ], 281 | "masters": [], 282 | "uuids": [ 283 | "c03b791b-60ef-4ae1-82b5-5c9ab6b4d08f" 284 | ] 285 | }, 286 | "sectors": "16775135", 287 | "sectorsize": 512, 288 | "size": "8.00 GB", 289 | "start": "2048", 290 | "uuid": "c03b791b-60ef-4ae1-82b5-5c9ab6b4d08f" 291 | } 292 | }, 293 | "removable": "0", 294 | "rotational": "0", 295 | "sas_address": null, 296 | "sas_device_handle": null, 297 | "scheduler_mode": "cfq", 298 | "sectors": "16777216", 299 | "sectorsize": "512", 300 | "size": "8.00 GB", 301 | "support_discard": "0", 302 | "vendor": null, 303 | "virtual": 1 304 | } 305 | }, 306 | "discovered_interpreter_python": "/usr/bin/python3", 307 | "distribution": "Ubuntu", 308 | "distribution_file_parsed": true, 309 | "distribution_file_path": "/etc/os-release", 310 | "distribution_file_variety": "Debian", 311 | "distribution_major_version": "18", 312 | "distribution_release": "bionic", 313 | "distribution_version": "18.04", 314 | "dns": { 315 | "nameservers": [ 316 | "127.0.0.53" 317 | ], 318 | "options": { 319 | "edns0": true 320 | }, 321 | "search": [ 322 | "us-east-2.compute.internal" 323 | ] 324 | }, 325 | "domain": "us-east-2.compute.internal", 326 | "effective_group_id": 1001, 327 | "effective_user_id": 1001, 328 | "env": { 329 | "HOME": "/home/ansibleuser", 330 | "LANG": "C", 331 | "LC_ALL": "C", 332 | "LC_CTYPE": "UTF-8", 333 | "LC_MESSAGES": "C", 334 | "LOGNAME": "ansibleuser", 335 | "MAIL": "/var/mail/ansibleuser", 336 | "PATH": "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games", 337 | "PWD": "/home/ansibleuser", 338 | "SHELL": "/bin/bash", 339 | "SHLVL": "1", 340 | "SSH_CLIENT": "51.252.105.91 1999 22", 341 | "SSH_CONNECTION": "51.252.105.91 1999 172.31.41.105 22", 342 | "SSH_TTY": "/dev/pts/1", 343 | "TERM": "screen", 344 | "USER": "ansibleuser", 345 | "XDG_RUNTIME_DIR": "/run/user/1001", 346 | "XDG_SESSION_ID": "8", 347 | "_": "/bin/sh" 348 | }, 349 | "eth0": { 350 | "active": true, 351 | "device": "eth0", 352 | "features": { 353 | "esp_hw_offload": "off [fixed]", 354 | "esp_tx_csum_hw_offload": "off [fixed]", 355 | "fcoe_mtu": "off [fixed]", 356 | "generic_receive_offload": "on", 357 | "generic_segmentation_offload": "on", 358 | "highdma": "off [fixed]", 359 | "hw_tc_offload": "off [fixed]", 360 | "l2_fwd_offload": "off [fixed]", 361 | "large_receive_offload": "off [fixed]", 362 | "loopback": "off [fixed]", 363 | "netns_local": "off [fixed]", 364 | "ntuple_filters": "off [fixed]", 365 | "receive_hashing": "off [fixed]", 366 | "rx_all": "off [fixed]", 367 | "rx_checksumming": "on [fixed]", 368 | "rx_fcs": "off [fixed]", 369 | "rx_udp_tunnel_port_offload": "off [fixed]", 370 | "rx_vlan_filter": "off [fixed]", 371 | "rx_vlan_offload": "off [fixed]", 372 | "rx_vlan_stag_filter": "off [fixed]", 373 | "rx_vlan_stag_hw_parse": "off [fixed]", 374 | "scatter_gather": "on", 375 | "tcp_segmentation_offload": "on", 376 | "tx_checksum_fcoe_crc": "off [fixed]", 377 | "tx_checksum_ip_generic": "off [fixed]", 378 | "tx_checksum_ipv4": "on [fixed]", 379 | "tx_checksum_ipv6": "off [requested on]", 380 | "tx_checksum_sctp": "off [fixed]", 381 | "tx_checksumming": "on", 382 | "tx_esp_segmentation": "off [fixed]", 383 | "tx_fcoe_segmentation": "off [fixed]", 384 | "tx_gre_csum_segmentation": "off [fixed]", 385 | "tx_gre_segmentation": "off [fixed]", 386 | "tx_gso_partial": "off [fixed]", 387 | "tx_gso_robust": "on [fixed]", 388 | "tx_ipxip4_segmentation": "off [fixed]", 389 | "tx_ipxip6_segmentation": "off [fixed]", 390 | "tx_lockless": "off [fixed]", 391 | "tx_nocache_copy": "off", 392 | "tx_scatter_gather": "on", 393 | "tx_scatter_gather_fraglist": "off [fixed]", 394 | "tx_sctp_segmentation": "off [fixed]", 395 | "tx_tcp6_segmentation": "off [requested on]", 396 | "tx_tcp_ecn_segmentation": "off [fixed]", 397 | "tx_tcp_mangleid_segmentation": "off", 398 | "tx_tcp_segmentation": "on", 399 | "tx_udp_tnl_csum_segmentation": "off [fixed]", 400 | "tx_udp_tnl_segmentation": "off [fixed]", 401 | "tx_vlan_offload": "off [fixed]", 402 | "tx_vlan_stag_hw_insert": "off [fixed]", 403 | "udp_fragmentation_offload": "off", 404 | "vlan_challenged": "off [fixed]" 405 | }, 406 | "hw_timestamp_filters": [], 407 | "ipv4": { 408 | "address": "172.31.41.105", 409 | "broadcast": "172.31.47.255", 410 | "netmask": "255.255.240.0", 411 | "network": "172.31.32.0" 412 | }, 413 | "ipv6": [ 414 | { 415 | "address": "fe80::89f:37ff:fe86:330", 416 | "prefix": "64", 417 | "scope": "link" 418 | } 419 | ], 420 | "macaddress": "0a:9f:37:86:03:30", 421 | "module": "xen_netfront", 422 | "mtu": 9001, 423 | "pciid": "vif-0", 424 | "promisc": false, 425 | "timestamping": [ 426 | "rx_software", 427 | "software" 428 | ], 429 | "type": "ether" 430 | }, 431 | "fibre_channel_wwn": [], 432 | "fips": false, 433 | "form_factor": "Other", 434 | "fqdn": "ip-172-31-41-105.us-east-2.compute.internal", 435 | "gather_subset": [ 436 | "all" 437 | ], 438 | "hostname": "ip-172-31-41-105", 439 | "hostnqn": "", 440 | "interfaces": [ 441 | "lo", 442 | "eth0" 443 | ], 444 | "is_chroot": false, 445 | "iscsi_iqn": "", 446 | "kernel": "4.15.0-1065-aws", 447 | "kernel_version": "#69-Ubuntu SMP Thu Mar 26 02:17:29 UTC 2020", 448 | "lo": { 449 | "active": true, 450 | "device": "lo", 451 | "features": { 452 | "esp_hw_offload": "off [fixed]", 453 | "esp_tx_csum_hw_offload": "off [fixed]", 454 | "fcoe_mtu": "off [fixed]", 455 | "generic_receive_offload": "on", 456 | "generic_segmentation_offload": "on", 457 | "highdma": "on [fixed]", 458 | "hw_tc_offload": "off [fixed]", 459 | "l2_fwd_offload": "off [fixed]", 460 | "large_receive_offload": "off [fixed]", 461 | "loopback": "on [fixed]", 462 | "netns_local": "on [fixed]", 463 | "ntuple_filters": "off [fixed]", 464 | "receive_hashing": "off [fixed]", 465 | "rx_all": "off [fixed]", 466 | "rx_checksumming": "on [fixed]", 467 | "rx_fcs": "off [fixed]", 468 | "rx_udp_tunnel_port_offload": "off [fixed]", 469 | "rx_vlan_filter": "off [fixed]", 470 | "rx_vlan_offload": "off [fixed]", 471 | "rx_vlan_stag_filter": "off [fixed]", 472 | "rx_vlan_stag_hw_parse": "off [fixed]", 473 | "scatter_gather": "on", 474 | "tcp_segmentation_offload": "on", 475 | "tx_checksum_fcoe_crc": "off [fixed]", 476 | "tx_checksum_ip_generic": "on [fixed]", 477 | "tx_checksum_ipv4": "off [fixed]", 478 | "tx_checksum_ipv6": "off [fixed]", 479 | "tx_checksum_sctp": "on [fixed]", 480 | "tx_checksumming": "on", 481 | "tx_esp_segmentation": "off [fixed]", 482 | "tx_fcoe_segmentation": "off [fixed]", 483 | "tx_gre_csum_segmentation": "off [fixed]", 484 | "tx_gre_segmentation": "off [fixed]", 485 | "tx_gso_partial": "off [fixed]", 486 | "tx_gso_robust": "off [fixed]", 487 | "tx_ipxip4_segmentation": "off [fixed]", 488 | "tx_ipxip6_segmentation": "off [fixed]", 489 | "tx_lockless": "on [fixed]", 490 | "tx_nocache_copy": "off [fixed]", 491 | "tx_scatter_gather": "on [fixed]", 492 | "tx_scatter_gather_fraglist": "on [fixed]", 493 | "tx_sctp_segmentation": "on", 494 | "tx_tcp6_segmentation": "on", 495 | "tx_tcp_ecn_segmentation": "on", 496 | "tx_tcp_mangleid_segmentation": "on", 497 | "tx_tcp_segmentation": "on", 498 | "tx_udp_tnl_csum_segmentation": "off [fixed]", 499 | "tx_udp_tnl_segmentation": "off [fixed]", 500 | "tx_vlan_offload": "off [fixed]", 501 | "tx_vlan_stag_hw_insert": "off [fixed]", 502 | "udp_fragmentation_offload": "off", 503 | "vlan_challenged": "on [fixed]" 504 | }, 505 | "hw_timestamp_filters": [], 506 | "ipv4": { 507 | "address": "127.0.0.1", 508 | "broadcast": "host", 509 | "netmask": "255.0.0.0", 510 | "network": "127.0.0.0" 511 | }, 512 | "ipv6": [ 513 | { 514 | "address": "::1", 515 | "prefix": "128", 516 | "scope": "host" 517 | } 518 | ], 519 | "mtu": 65536, 520 | "promisc": false, 521 | "timestamping": [ 522 | "tx_software", 523 | "rx_software", 524 | "software" 525 | ], 526 | "type": "loopback" 527 | }, 528 | "lsb": { 529 | "codename": "bionic", 530 | "description": "Ubuntu 18.04.3 LTS", 531 | "id": "Ubuntu", 532 | "major_release": "18", 533 | "release": "18.04" 534 | }, 535 | "machine": "x86_64", 536 | "machine_id": "15fc86df26ec4f30b0b01495064c0b42", 537 | "memfree_mb": 371, 538 | "memory_mb": { 539 | "nocache": { 540 | "free": 834, 541 | "used": 149 542 | }, 543 | "real": { 544 | "free": 371, 545 | "total": 983, 546 | "used": 612 547 | }, 548 | "swap": { 549 | "cached": 0, 550 | "free": 0, 551 | "total": 0, 552 | "used": 0 553 | } 554 | }, 555 | "memtotal_mb": 983, 556 | "module_setup": true, 557 | "mounts": [ 558 | { 559 | "block_available": 1572556, 560 | "block_size": 4096, 561 | "block_total": 2016361, 562 | "block_used": 443805, 563 | "device": "/dev/xvda1", 564 | "fstype": "ext4", 565 | "inode_available": 931687, 566 | "inode_total": 1024000, 567 | "inode_used": 92313, 568 | "mount": "/", 569 | "options": "rw,relatime,discard,data=ordered", 570 | "size_available": 6441189376, 571 | "size_total": 8259014656, 572 | "uuid": "c03b791b-60ef-4ae1-82b5-5c9ab6b4d08f" 573 | }, 574 | { 575 | "block_available": 0, 576 | "block_size": 131072, 577 | "block_total": 751, 578 | "block_used": 751, 579 | "device": "/dev/loop0", 580 | "fstype": "squashfs", 581 | "inode_available": 0, 582 | "inode_total": 12852, 583 | "inode_used": 12852, 584 | "mount": "/snap/core/8935", 585 | "options": "ro,nodev,relatime", 586 | "size_available": 0, 587 | "size_total": 98435072, 588 | "uuid": "N/A" 589 | }, 590 | { 591 | "block_available": 0, 592 | "block_size": 131072, 593 | "block_total": 144, 594 | "block_used": 144, 595 | "device": "/dev/loop1", 596 | "fstype": "squashfs", 597 | "inode_available": 0, 598 | "inode_total": 15, 599 | "inode_used": 15, 600 | "mount": "/snap/amazon-ssm-agent/1566", 601 | "options": "ro,nodev,relatime", 602 | "size_available": 0, 603 | "size_total": 18874368, 604 | "uuid": "N/A" 605 | }, 606 | { 607 | "block_available": 0, 608 | "block_size": 131072, 609 | "block_total": 144, 610 | "block_used": 144, 611 | "device": "/dev/loop2", 612 | "fstype": "squashfs", 613 | "inode_available": 0, 614 | "inode_total": 15, 615 | "inode_used": 15, 616 | "mount": "/snap/amazon-ssm-agent/1480", 617 | "options": "ro,nodev,relatime", 618 | "size_available": 0, 619 | "size_total": 18874368, 620 | "uuid": "N/A" 621 | }, 622 | { 623 | "block_available": 0, 624 | "block_size": 131072, 625 | "block_total": 752, 626 | "block_used": 752, 627 | "device": "/dev/loop3", 628 | "fstype": "squashfs", 629 | "inode_available": 0, 630 | "inode_total": 12857, 631 | "inode_used": 12857, 632 | "mount": "/snap/core/9066", 633 | "options": "ro,nodev,relatime", 634 | "size_available": 0, 635 | "size_total": 98566144, 636 | "uuid": "N/A" 637 | } 638 | ], 639 | "nodename": "ip-172-31-41-105", 640 | "os_family": "Debian", 641 | "pkg_mgr": "apt", 642 | "proc_cmdline": { 643 | "BOOT_IMAGE": "/boot/vmlinuz-4.15.0-1065-aws", 644 | "console": [ 645 | "tty1", 646 | "ttyS0" 647 | ], 648 | "nvme_core.io_timeout": "4294967295", 649 | "ro": true, 650 | "root": "UUID=c03b791b-60ef-4ae1-82b5-5c9ab6b4d08f" 651 | }, 652 | "processor": [ 653 | "0", 654 | "GenuineIntel", 655 | "Intel(R) Xeon(R) CPU E5-2676 v3 @ 2.40GHz" 656 | ], 657 | "processor_cores": 1, 658 | "processor_count": 1, 659 | "processor_threads_per_core": 1, 660 | "processor_vcpus": 1, 661 | "product_name": "HVM domU", 662 | "product_serial": "NA", 663 | "product_uuid": "NA", 664 | "product_version": "4.2.amazon", 665 | "python": { 666 | "executable": "/usr/bin/python3", 667 | "has_sslcontext": true, 668 | "type": "cpython", 669 | "version": { 670 | "major": 3, 671 | "micro": 9, 672 | "minor": 6, 673 | "releaselevel": "final", 674 | "serial": 0 675 | }, 676 | "version_info": [ 677 | 3, 678 | 6, 679 | 9, 680 | "final", 681 | 0 682 | ] 683 | }, 684 | "python_version": "3.6.9", 685 | "real_group_id": 1001, 686 | "real_user_id": 1001, 687 | "selinux": { 688 | "status": "Missing selinux Python library" 689 | }, 690 | "selinux_python_present": false, 691 | "service_mgr": "systemd", 692 | "ssh_host_key_dsa_public": "AAAAB3NzaC1kc3MAAACBAL+cucu16IttP9Xucj3DZyv9ojNlt780bf7Ze8nRbpKcNIQsYwUdLp0EI1B4uiii2j2BpAG7HKEhRO06HFlVIC3293KBGpZusH6v+KrFrduZNWODUq/ECSUIK7xyIKGMAr1ibMo9jcqI6xcJuG/Q9/AW5GUPTjaX8c+uAraeFkbxAAAAFQDjTyiYtABDIo7c1ZXl99ycglI0iQAAAIBJWbjCGNAMWQY4+oW4sJvDKLS7AG8ywFD1ND8mm/ob8IY5z3tfXWj2EHQ1ssc677KXdjHwEX20WL4/tYPPdHvlXuyIrou1WnovuX6426+DavlBTVvvWCam9ukyoeYHLKFnhRvV4do6QcTJn2eeGxxH4FLC4Rr/04G6TzTP1OxzsAAAAIAgWo1cOUKQNrRsr9BYUPkwk43iEj8ii6r7qRFIVCqceH/xmqD+IRHzr+mmTFPKkb6u/mnQrV3LTKpTJ3Hu7JOoflEkCW30R6h5RX6CCGcixljDutKUUWtW0R1ghYdKeUq+iRw6ohoe8SZTP578u7zh2mkW6zBhPVhoJNZmW0Tsaw==", 693 | "ssh_host_key_ecdsa_public": "AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBGeQBV7CEVxwtVO69kj/6HkZWb8HnOT2MZ5JhXTOge8h1RXXE2OqKoSlqIVQ3Mznsrjlph2rBTiTUx4XM66mry0=", 694 | "ssh_host_key_ed25519_public": "AAAAC3NzaC1lZDI1NTE5AAAAIBxsY3IdhWWcBqFXqPHgXRrdLb681TU7xx3iHbKiqnDg", 695 | "ssh_host_key_rsa_public": "AAAAB3NzaC1yc2EAAAADAQABAAABAQDSBIrFDnhbZQfO7uAQQ/pVR6jBy/hl7qCosQBZ1u9T7ROWUPBrpklfeMgUbjxZn4kSFcgrFe8EiTjaVXHfWhs1QKYsmPgIQgP6X/bbkEBCDrErOGYYW15im1ff5YEQfG0VTAEoJF1d7dtIdyUGn13RrnHUd7U9QqHHY2dzZl9CNugaR3Q3/8mUrtCE4eXCpqqAENI9WvHg7Mgui7rcIXOnJi3mNy6atyohDoB2hagFWHU9ZMK1t6bJTF8GAzupTvtZic2J1IN5hj4fQR6+Qudg06LDNXsU7t45KkUElTuUwX6TtOFBJce3h12KkEjRmUQ0XhI/dKELf3u4HkDx2eCV", 696 | "swapfree_mb": 0, 697 | "swaptotal_mb": 0, 698 | "system": "Linux", 699 | "system_capabilities": [ 700 | "" 701 | ], 702 | "system_capabilities_enforced": "True", 703 | "system_vendor": "Xen", 704 | "uptime_seconds": 4343, 705 | "user_dir": "/home/ansibleuser", 706 | "user_gecos": "", 707 | "user_gid": 1001, 708 | "user_id": "ansibleuser", 709 | "user_shell": "/bin/bash", 710 | "user_uid": 1001, 711 | "userspace_architecture": "x86_64", 712 | "userspace_bits": "64", 713 | "virtualization_role": "guest", 714 | "virtualization_type": "xen" 715 | } 716 | } 717 | 718 | PLAY RECAP ********************************************************************* 719 | ec2 : ok=2 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 720 | 721 | --------------------------------------------------------------------------------