chrisluiz16

Rolling update day 10

Jul 1st, 2023
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 70.09 KB | None | 0 0
  1.  
  2. ---------------------------------- Task 1 Vars ---------------
  3.  
  4.  
  5.  
  6.  
  7.  
  8. [ec2-user@ip-172-31-6-232 ~]$ cat main.yml
  9. ---
  10.  
  11. - name: "Variables priority checking"
  12.   hosts: localhost
  13.   vars:
  14.     myvars: "This is the var in play level"
  15.   vars_files:
  16.    - vars.yml
  17.   tasks:
  18.     - name: "debugging the vars priority"
  19.       debug:
  20.         var: myvars
  21.  
  22.  
  23.  
  24. ### Output ####
  25.  
  26. [ec2-user@ip-172-31-6-232 ~]$ ansible-playbook main.yml
  27.  
  28. PLAY [Variables priority checking] *************************************************************************************
  29.  
  30. TASK [Gathering Facts] *************************************************************************************************
  31. ok: [localhost]
  32.  
  33. TASK [debugging the vars priority] *************************************************************************************
  34. ok: [localhost] => {
  35.     "myvars": "You are seeing the vars_file result"
  36. }
  37.  
  38. PLAY RECAP *************************************************************************************************************
  39. localhost                  : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
  40.  
  41.  
  42.  
  43. #### Command line execution ####
  44.  
  45.  
  46. [ec2-user@ip-172-31-6-232 ~]$ ansible-playbook main.yml -e myvars='"You are seeing the command line executed vars"'
  47.  
  48. PLAY [Variables priority checking] *************************************************************************************
  49.  
  50. TASK [Gathering Facts] *************************************************************************************************
  51. ok: [localhost]
  52.  
  53. TASK [debugging the vars priority] *************************************************************************************
  54. ok: [localhost] => {
  55.     "myvars": "You are seeing the command line executed vars"
  56. }
  57.  
  58. PLAY RECAP *************************************************************************************************************
  59. localhost                  : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
  60.  
  61.  
  62.  
  63. ### Task leve execution ###
  64.  
  65. ---
  66.  
  67. - name: "Variables priority checking"
  68.   hosts: localhost
  69.   vars:
  70.     myvars: "This is the var in play level"
  71.   vars_files:
  72.    - vars.yml
  73.   tasks:
  74.     - name: "debugging the vars priority"
  75.       vars:
  76.         myvars: "You are seeing the var result in task level"
  77.       debug:
  78.         var: myvars
  79.        
  80.  
  81.  
  82. ### Output ####
  83.  
  84.  
  85. [ec2-user@ip-172-31-6-232 ~]$ ansible-playbook main.yml'
  86.  
  87. PLAY [Variables priority checking] *************************************************************************************
  88.  
  89. TASK [Gathering Facts] *************************************************************************************************
  90. ok: [localhost]
  91.  
  92. TASK [debugging the vars priority] *************************************************************************************
  93. ok: [localhost] => {
  94.     "myvars": "You are seeing the var result in task level"
  95. }
  96.  
  97. PLAY RECAP *************************************************************************************************************
  98. localhost                  : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
  99.  
  100.  
  101.  
  102.  
  103. #### Rolling update ####
  104.  
  105.  
  106. ---
  107.  
  108. - name: "Creating a dynamic inventory for Zomato-infra"
  109.   hosts: localhost
  110.   become: true
  111.   vars:
  112.     pip_modules:
  113.      - boto3
  114.       - botocore
  115.   vars_files:
  116.    - config.yml
  117.   tasks:
  118.     - name: "Ansible galaxy installl aws collection"
  119.       community.general.ansible_galaxy_install:
  120.         type: collection
  121.         name: amazon.aws
  122.     - name: "Install python3-pip module"
  123.       yum:
  124.         name: python3-pip
  125.         state: present
  126.     - name: "Install pip3 modules for amazon.aws"
  127.       pip:
  128.         name: "{{ pip_modules }}"
  129.     - name: "Collect aws ec2-instance info of zomato-infra"
  130.       amazon.aws.ec2_instance_info:
  131.         access_key: "{{ access_key }}"
  132.         secret_key: "{{ secret_key }}"
  133.         region: ap-south-1
  134.         filters:
  135.           "tag:Name": "Zomato-webserver"
  136.           "tag:aws:autoscaling:groupName": "shopping-asg"
  137.           "tag:Project": "Zomato"
  138.           "tag:Env": "Dev"
  139.       register: zomato_status
  140.     - name: "Creating a dynamic inventory"
  141.       add_host:
  142.         hostname: "{{ item.private_ip_address }}"
  143.         groups: Zomato-infra
  144.         ansible_ssh_host: "{{ item.private_ip_address }}"
  145.         ansible_ssh_user: ec2-user
  146.         ansible_ssh_private_key_file: ./aws.pem
  147.         ansible_ssh_common_args: "-o StrictHostKeyChecking=no"
  148.         ansible_python_interpreter: auto_silent
  149.       with_items:
  150.        - "{{ zomato_status.instances }}"
  151. - name: "Rolling update"
  152.   hosts: Zomato-infra
  153.   serial: 1
  154.   become: true
  155.   vars:
  156.     packages:
  157.      - httpd
  158.       - php-fpm
  159.       - git
  160.     git_url: https://github.com/Chris-luiz-16/aws-elb-site.git
  161.     git_dest: /var/website/
  162.     docroot: /var/www/html/
  163.     httpd_owner: apache
  164.   tasks:
  165.     - name: "Installing required packages"
  166.       yum:
  167.         name: "{{ packages }}"
  168.         state: present
  169.     - name: "Cloning the git rep to {{ git_dest }}"
  170.       git:
  171.         repo: "{{ git_url }}"
  172.         dest: "{{ git_dest }}"
  173.       register: git_status
  174.     - name: "Draining the clb"
  175.       when: git_status.changed == true
  176.       service:
  177.         name: httpd
  178.         state: stopped
  179.     - name: "Making sure the connection draining time interval is matched"
  180.       when: git_status.changed == true
  181.       wait_for:
  182.         timeout: 30
  183.     - name: "Copying the website to docroot"
  184.       when: git_status.changed == true
  185.       copy:
  186.         src: "{{ git_dest }}"
  187.         dest: "{{ docroot }}"
  188.         remote_src: true
  189.         owner: "{{ httpd_owner }}"
  190.         group: "{{ httpd_owner }}"
  191.     - name: "Attaching it to clb"
  192.       when: git_status.changed == true
  193.       service:
  194.         name: httpd
  195.         state: started
  196.     - name: "Healthy status in-service"
  197.       when: git_status.changed == true
  198.       wait_for:
  199.         timeout: 30
  200.  
  201.  
  202.  
  203. #### Output with no version update ####
  204.  
  205. [ec2-user@ip-172-31-6-232 ~]$ ansible-playbook aws.yml --vault-password-file=passwd.sh
  206. [WARNING]: No inventory was parsed, only implicit localhost is available
  207. [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match
  208. 'all'
  209.  
  210. PLAY [Creating a dynamic inventory for Zomato-infra] *******************************************************************
  211.  
  212. TASK [Gathering Facts] *************************************************************************************************
  213. ok: [localhost]
  214.  
  215. TASK [Ansible galaxy installl aws collection] **************************************************************************
  216. ok: [localhost]
  217.  
  218. TASK [Install python3-pip module] **************************************************************************************
  219. ok: [localhost]
  220.  
  221. TASK [Install pip3 modules for amazon.aws] *****************************************************************************
  222. ok: [localhost]
  223.  
  224. TASK [Collect aws ec2-instance info of zomato-infra] *******************************************************************
  225. ok: [localhost]
  226.  
  227. TASK [Creating a dynamic inventory] ************************************************************************************
  228. changed: [localhost] => (item={'ami_launch_index': 1, 'image_id': 'ami-0b9ecf71fe947bbdd', 'instance_id': 'i-008fc4bdb8ba86fb3', 'instance_type': 't2.micro', 'key_name': 'mumbai-new', 'launch_time': '2023-07-01T11:11:36+00:00', 'monitoring': {'state': 'disabled'}, 'placement': {'availability_zone': 'ap-south-1a', 'group_name': '', 'tenancy': 'default'}, 'private_dns_name': 'ip-172-31-45-142.ap-south-1.compute.internal', 'private_ip_address': '172.31.45.142', 'product_codes': [], 'public_dns_name': 'ec2-13-127-88-76.ap-south-1.compute.amazonaws.com', 'public_ip_address': '13.127.88.76', 'state': {'code': 16, 'name': 'running'}, 'state_transition_reason': '', 'subnet_id': 'subnet-03d5cac27f2ede1f4', 'vpc_id': 'vpc-06e13c7cdf3e917f5', 'architecture': 'x86_64', 'block_device_mappings': [{'device_name': '/dev/xvda', 'ebs': {'attach_time': '2023-07-01T11:11:37+00:00', 'delete_on_termination': True, 'status': 'attached', 'volume_id': 'vol-0d60b31054268e467'}}], 'client_token': 'ef762444-9ac3-8fd3-f62d-c81f56de514d', 'ebs_optimized': False, 'ena_support': True, 'hypervisor': 'xen', 'network_interfaces': [{'association': {'ip_owner_id': 'amazon', 'public_dns_name': 'ec2-13-127-88-76.ap-south-1.compute.amazonaws.com', 'public_ip': '13.127.88.76'}, 'attachment': {'attach_time': '2023-07-01T11:11:36+00:00', 'attachment_id': 'eni-attach-066ae20667796d516', 'delete_on_termination': True, 'device_index': 0, 'status': 'attached', 'network_card_index': 0}, 'description': '', 'groups': [{'group_name': 'Freedom', 'group_id': 'sg-09a5a43f8400c81c4'}], 'ipv6_addresses': [], 'mac_address': '02:e2:19:35:2f:64', 'network_interface_id': 'eni-0002514e9fdfeb2ef', 'owner_id': '945577359662', 'private_dns_name': 'ip-172-31-45-142.ap-south-1.compute.internal', 'private_ip_address': '172.31.45.142', 'private_ip_addresses': [{'association': {'ip_owner_id': 'amazon', 'public_dns_name': 'ec2-13-127-88-76.ap-south-1.compute.amazonaws.com', 'public_ip': '13.127.88.76'}, 'primary': True, 'private_dns_name': 'ip-172-31-45-142.ap-south-1.compute.internal', 'private_ip_address': '172.31.45.142'}], 'source_dest_check': True, 'status': 'in-use', 'subnet_id': 'subnet-03d5cac27f2ede1f4', 'vpc_id': 'vpc-06e13c7cdf3e917f5', 'interface_type': 'interface'}], 'root_device_name': '/dev/xvda', 'root_device_type': 'ebs', 'security_groups': [{'group_name': 'Freedom', 'group_id': 'sg-09a5a43f8400c81c4'}], 'source_dest_check': True, 'tags': {'Name': 'Zomato-webserver', 'Env': 'Dev', 'Project': 'Zomato', 'aws:autoscaling:groupName': 'shopping-asg', 'aws:ec2launchtemplate:id': 'lt-0acf1324f7d389679', 'aws:ec2launchtemplate:version': '1'}, 'virtualization_type': 'hvm', 'cpu_options': {'core_count': 1, 'threads_per_core': 1}, 'capacity_reservation_specification': {'capacity_reservation_preference': 'open'}, 'hibernation_options': {'configured': False}, 'metadata_options': {'state': 'applied', 'http_tokens': 'required', 'http_put_response_hop_limit': 2, 'http_endpoint': 'enabled', 'http_protocol_ipv6': 'disabled', 'instance_metadata_tags': 'disabled'}, 'enclave_options': {'enabled': False}, 'boot_mode': 'uefi-preferred', 'platform_details': 'Linux/UNIX', 'usage_operation': 'RunInstances', 'usage_operation_update_time': '2023-07-01T11:11:36+00:00', 'private_dns_name_options': {'hostname_type': 'ip-name', 'enable_resource_name_dns_a_record': False, 'enable_resource_name_dns_aaaa_record': False}, 'maintenance_options': {'auto_recovery': 'default'}, 'current_instance_boot_mode': 'legacy-bios'})
  229. changed: [localhost] => (item={'ami_launch_index': 0, 'image_id': 'ami-0b9ecf71fe947bbdd', 'instance_id': 'i-0ac06441ba2439468', 'instance_type': 't2.micro', 'key_name': 'mumbai-new', 'launch_time': '2023-07-01T11:11:36+00:00', 'monitoring': {'state': 'disabled'}, 'placement': {'availability_zone': 'ap-south-1a', 'group_name': '', 'tenancy': 'default'}, 'private_dns_name': 'ip-172-31-40-50.ap-south-1.compute.internal', 'private_ip_address': '172.31.40.50', 'product_codes': [], 'public_dns_name': 'ec2-35-154-112-147.ap-south-1.compute.amazonaws.com', 'public_ip_address': '35.154.112.147', 'state': {'code': 16, 'name': 'running'}, 'state_transition_reason': '', 'subnet_id': 'subnet-03d5cac27f2ede1f4', 'vpc_id': 'vpc-06e13c7cdf3e917f5', 'architecture': 'x86_64', 'block_device_mappings': [{'device_name': '/dev/xvda', 'ebs': {'attach_time': '2023-07-01T11:11:37+00:00', 'delete_on_termination': True, 'status': 'attached', 'volume_id': 'vol-022067d2a2c37d3b1'}}], 'client_token': 'ef762444-9ac3-8fd3-f62d-c81f56de514d', 'ebs_optimized': False, 'ena_support': True, 'hypervisor': 'xen', 'network_interfaces': [{'association': {'ip_owner_id': 'amazon', 'public_dns_name': 'ec2-35-154-112-147.ap-south-1.compute.amazonaws.com', 'public_ip': '35.154.112.147'}, 'attachment': {'attach_time': '2023-07-01T11:11:36+00:00', 'attachment_id': 'eni-attach-0e4b82096408ffd6e', 'delete_on_termination': True, 'device_index': 0, 'status': 'attached', 'network_card_index': 0}, 'description': '', 'groups': [{'group_name': 'Freedom', 'group_id': 'sg-09a5a43f8400c81c4'}], 'ipv6_addresses': [], 'mac_address': '02:90:41:bb:ba:8e', 'network_interface_id': 'eni-00a5fe13f3a812d26', 'owner_id': '945577359662', 'private_dns_name': 'ip-172-31-40-50.ap-south-1.compute.internal', 'private_ip_address': '172.31.40.50', 'private_ip_addresses': [{'association': {'ip_owner_id': 'amazon', 'public_dns_name': 'ec2-35-154-112-147.ap-south-1.compute.amazonaws.com', 'public_ip': '35.154.112.147'}, 'primary': True, 'private_dns_name': 'ip-172-31-40-50.ap-south-1.compute.internal', 'private_ip_address': '172.31.40.50'}], 'source_dest_check': True, 'status': 'in-use', 'subnet_id': 'subnet-03d5cac27f2ede1f4', 'vpc_id': 'vpc-06e13c7cdf3e917f5', 'interface_type': 'interface'}], 'root_device_name': '/dev/xvda', 'root_device_type': 'ebs', 'security_groups': [{'group_name': 'Freedom', 'group_id': 'sg-09a5a43f8400c81c4'}], 'source_dest_check': True, 'tags': {'aws:ec2launchtemplate:version': '1', 'Name': 'Zomato-webserver', 'aws:ec2launchtemplate:id': 'lt-0acf1324f7d389679', 'aws:autoscaling:groupName': 'shopping-asg', 'Env': 'Dev', 'Project': 'Zomato'}, 'virtualization_type': 'hvm', 'cpu_options': {'core_count': 1, 'threads_per_core': 1}, 'capacity_reservation_specification': {'capacity_reservation_preference': 'open'}, 'hibernation_options': {'configured': False}, 'metadata_options': {'state': 'applied', 'http_tokens': 'required', 'http_put_response_hop_limit': 2, 'http_endpoint': 'enabled', 'http_protocol_ipv6': 'disabled', 'instance_metadata_tags': 'disabled'}, 'enclave_options': {'enabled': False}, 'boot_mode': 'uefi-preferred', 'platform_details': 'Linux/UNIX', 'usage_operation': 'RunInstances', 'usage_operation_update_time': '2023-07-01T11:11:36+00:00', 'private_dns_name_options': {'hostname_type': 'ip-name', 'enable_resource_name_dns_a_record': False, 'enable_resource_name_dns_aaaa_record': False}, 'maintenance_options': {'auto_recovery': 'default'}, 'current_instance_boot_mode': 'legacy-bios'})
  230. changed: [localhost] => (item={'ami_launch_index': 0, 'image_id': 'ami-0b9ecf71fe947bbdd', 'instance_id': 'i-0b4761ec172352872', 'instance_type': 't2.micro', 'key_name': 'mumbai-new', 'launch_time': '2023-07-01T11:11:36+00:00', 'monitoring': {'state': 'disabled'}, 'placement': {'availability_zone': 'ap-south-1b', 'group_name': '', 'tenancy': 'default'}, 'private_dns_name': 'ip-172-31-2-19.ap-south-1.compute.internal', 'private_ip_address': '172.31.2.19', 'product_codes': [], 'public_dns_name': 'ec2-65-0-87-36.ap-south-1.compute.amazonaws.com', 'public_ip_address': '65.0.87.36', 'state': {'code': 16, 'name': 'running'}, 'state_transition_reason': '', 'subnet_id': 'subnet-0c662917265d9d0e9', 'vpc_id': 'vpc-06e13c7cdf3e917f5', 'architecture': 'x86_64', 'block_device_mappings': [{'device_name': '/dev/xvda', 'ebs': {'attach_time': '2023-07-01T11:11:37+00:00', 'delete_on_termination': True, 'status': 'attached', 'volume_id': 'vol-0dd243cd99ffbc8ba'}}], 'client_token': '46862444-9ac2-9a4e-f074-06936da27bb3', 'ebs_optimized': False, 'ena_support': True, 'hypervisor': 'xen', 'network_interfaces': [{'association': {'ip_owner_id': 'amazon', 'public_dns_name': 'ec2-65-0-87-36.ap-south-1.compute.amazonaws.com', 'public_ip': '65.0.87.36'}, 'attachment': {'attach_time': '2023-07-01T11:11:36+00:00', 'attachment_id': 'eni-attach-013c3173b26695722', 'delete_on_termination': True, 'device_index': 0, 'status': 'attached', 'network_card_index': 0}, 'description': '', 'groups': [{'group_name': 'Freedom', 'group_id': 'sg-09a5a43f8400c81c4'}], 'ipv6_addresses': [], 'mac_address': '0a:ea:d0:e7:b0:54', 'network_interface_id': 'eni-059263a4b61df6a21', 'owner_id': '945577359662', 'private_dns_name': 'ip-172-31-2-19.ap-south-1.compute.internal', 'private_ip_address': '172.31.2.19', 'private_ip_addresses': [{'association': {'ip_owner_id': 'amazon', 'public_dns_name': 'ec2-65-0-87-36.ap-south-1.compute.amazonaws.com', 'public_ip': '65.0.87.36'}, 'primary': True, 'private_dns_name': 'ip-172-31-2-19.ap-south-1.compute.internal', 'private_ip_address': '172.31.2.19'}], 'source_dest_check': True, 'status': 'in-use', 'subnet_id': 'subnet-0c662917265d9d0e9', 'vpc_id': 'vpc-06e13c7cdf3e917f5', 'interface_type': 'interface'}], 'root_device_name': '/dev/xvda', 'root_device_type': 'ebs', 'security_groups': [{'group_name': 'Freedom', 'group_id': 'sg-09a5a43f8400c81c4'}], 'source_dest_check': True, 'tags': {'Env': 'Dev', 'aws:ec2launchtemplate:version': '1', 'aws:ec2launchtemplate:id': 'lt-0acf1324f7d389679', 'Project': 'Zomato', 'aws:autoscaling:groupName': 'shopping-asg', 'Name': 'Zomato-webserver'}, 'virtualization_type': 'hvm', 'cpu_options': {'core_count': 1, 'threads_per_core': 1}, 'capacity_reservation_specification': {'capacity_reservation_preference': 'open'}, 'hibernation_options': {'configured': False}, 'metadata_options': {'state': 'applied', 'http_tokens': 'required', 'http_put_response_hop_limit': 2, 'http_endpoint': 'enabled', 'http_protocol_ipv6': 'disabled', 'instance_metadata_tags': 'disabled'}, 'enclave_options': {'enabled': False}, 'boot_mode': 'uefi-preferred', 'platform_details': 'Linux/UNIX', 'usage_operation': 'RunInstances', 'usage_operation_update_time': '2023-07-01T11:11:36+00:00', 'private_dns_name_options': {'hostname_type': 'ip-name', 'enable_resource_name_dns_a_record': False, 'enable_resource_name_dns_aaaa_record': False}, 'maintenance_options': {'auto_recovery': 'default'}, 'current_instance_boot_mode': 'legacy-bios'})
  231.  
  232. PLAY [Rolling update] **************************************************************************************************
  233.  
  234. TASK [Gathering Facts] *************************************************************************************************
  235. ok: [172.31.45.142]
  236.  
  237. TASK [Installing required packages] ************************************************************************************
  238. ok: [172.31.45.142]
  239.  
  240. TASK [Cloning the git rep to /var/website] *****************************************************************************
  241. ok: [172.31.45.142]
  242.  
  243. TASK [Draining the clb] ************************************************************************************************
  244. skipping: [172.31.45.142]
  245.  
  246. TASK [Making sure the connection draining time interval is matched] ****************************************************
  247. skipping: [172.31.45.142]
  248.  
  249. TASK [Copying the website to docroot] **********************************************************************************
  250. skipping: [172.31.45.142]
  251.  
  252. TASK [Attaching it to clb] *********************************************************************************************
  253. skipping: [172.31.45.142]
  254.  
  255. TASK [Healthy status in-service] ***************************************************************************************
  256. skipping: [172.31.45.142]
  257.  
  258. PLAY [Rolling update] **************************************************************************************************
  259.  
  260. TASK [Gathering Facts] *************************************************************************************************
  261. ok: [172.31.40.50]
  262.  
  263. TASK [Installing required packages] ************************************************************************************
  264. ok: [172.31.40.50]
  265.  
  266. TASK [Cloning the git rep to /var/website] *****************************************************************************
  267. ok: [172.31.40.50]
  268.  
  269. TASK [Draining the clb] ************************************************************************************************
  270. skipping: [172.31.40.50]
  271.  
  272. TASK [Making sure the connection draining time interval is matched] ****************************************************
  273. skipping: [172.31.40.50]
  274.  
  275. TASK [Copying the website to docroot] **********************************************************************************
  276. skipping: [172.31.40.50]
  277.  
  278. TASK [Attaching it to clb] *********************************************************************************************
  279. skipping: [172.31.40.50]
  280.  
  281. TASK [Healthy status in-service] ***************************************************************************************
  282. skipping: [172.31.40.50]
  283.  
  284. PLAY [Rolling update] **************************************************************************************************
  285.  
  286. TASK [Gathering Facts] *************************************************************************************************
  287. ok: [172.31.2.19]
  288.  
  289. TASK [Installing required packages] ************************************************************************************
  290. ok: [172.31.2.19]
  291.  
  292. TASK [Cloning the git rep to /var/website] *****************************************************************************
  293. ok: [172.31.2.19]
  294.  
  295. TASK [Draining the clb] ************************************************************************************************
  296. skipping: [172.31.2.19]
  297.  
  298. TASK [Making sure the connection draining time interval is matched] ****************************************************
  299. skipping: [172.31.2.19]
  300.  
  301. TASK [Copying the website to docroot] **********************************************************************************
  302. skipping: [172.31.2.19]
  303.  
  304. TASK [Attaching it to clb] *********************************************************************************************
  305. skipping: [172.31.2.19]
  306.  
  307. TASK [Healthy status in-service] ***************************************************************************************
  308. skipping: [172.31.2.19]
  309.  
  310. PLAY RECAP *************************************************************************************************************
  311. 172.31.2.19                : ok=3    changed=0    unreachable=0    failed=0    skipped=5    rescued=0    ignored=0
  312. 172.31.40.50               : ok=3    changed=0    unreachable=0    failed=0    skipped=5    rescued=0    ignored=0
  313. 172.31.45.142              : ok=3    changed=0    unreachable=0    failed=0    skipped=5    rescued=0    ignored=0
  314. localhost                  : ok=6    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
  315.  
  316.  
  317.  
  318. #### Output after git repo version update ####
  319.  
  320. [ec2-user@ip-172-31-6-232 ~]$ ansible-playbook aws.yml --vault-password-file=passwd.sh
  321.  
  322.  
  323. PLAY [Creating a dynamic inventory for Zomato-infra] *******************************************************************
  324.  
  325. TASK [Gathering Facts] *************************************************************************************************
  326. ok: [localhost]
  327.  
  328. TASK [Ansible galaxy installl aws collection] **************************************************************************
  329. ok: [localhost]
  330.  
  331. TASK [Install python3-pip module] **************************************************************************************
  332. ok: [localhost]
  333.  
  334. TASK [Install pip3 modules for amazon.aws] *****************************************************************************
  335. ok: [localhost]
  336.  
  337. TASK [Collect aws ec2-instance info of zomato-infra] *******************************************************************
  338. ok: [localhost]
  339.  
  340. TASK [Creating a dynamic inventory] ************************************************************************************
  341.  
  342. changed: [localhost] => (item={'ami_launch_index': 1, 'image_id': 'ami-0b9ecf71fe947bbdd', 'instance_id': 'i-008fc4bdb8ba86fb3', 'instance_type': 't2.micro', 'key_name': 'mumbai-new', 'launch_time': '2023-07-01T11:11:36+00:00', 'monitoring': {'state': 'disabled'}, 'placement': {'availability_zone': 'ap-south-1a', 'group_name': '', 'tenancy': 'default'}, 'private_dns_name': 'ip-172-31-45-142.ap-south-1.compute.internal', 'private_ip_address': '172.31.45.142', 'product_codes': [], 'public_dns_name': 'ec2-13-127-88-76.ap-south-1.compute.amazonaws.com', 'public_ip_address': '13.127.88.76', 'state': {'code': 16, 'name': 'running'}, 'state_transition_reason': '', 'subnet_id': 'subnet-03d5cac27f2ede1f4', 'vpc_id': 'vpc-06e13c7cdf3e917f5', 'architecture': 'x86_64', 'block_device_mappings': [{'device_name': '/dev/xvda', 'ebs': {'attach_time': '2023-07-01T11:11:37+00:00', 'delete_on_termination': True, 'status': 'attached', 'volume_id': 'vol-0d60b31054268e467'}}], 'client_token': 'ef762444-9ac3-8fd3-f62d-c81f56de514d', 'ebs_optimized': False, 'ena_support': True, 'hypervisor': 'xen', 'network_interfaces': [{'association': {'ip_owner_id': 'amazon', 'public_dns_name': 'ec2-13-127-88-76.ap-south-1.compute.amazonaws.com', 'public_ip': '13.127.88.76'}, 'attachment': {'attach_time': '2023-07-01T11:11:36+00:00', 'attachment_id': 'eni-attach-066ae20667796d516', 'delete_on_termination': True, 'device_index': 0, 'status': 'attached', 'network_card_index': 0}, 'description': '', 'groups': [{'group_name': 'Freedom', 'group_id': 'sg-09a5a43f8400c81c4'}], 'ipv6_addresses': [], 'mac_address': '02:e2:19:35:2f:64', 'network_interface_id': 'eni-0002514e9fdfeb2ef', 'owner_id': '945577359662', 'private_dns_name': 'ip-172-31-45-142.ap-south-1.compute.internal', 'private_ip_address': '172.31.45.142', 'private_ip_addresses': [{'association': {'ip_owner_id': 'amazon', 'public_dns_name': 'ec2-13-127-88-76.ap-south-1.compute.amazonaws.com', 'public_ip': '13.127.88.76'}, 'primary': True, 'private_dns_name': 'ip-172-31-45-142.ap-south-1.compute.internal', 'private_ip_address': '172.31.45.142'}], 'source_dest_check': True, 'status': 'in-use', 'subnet_id': 'subnet-03d5cac27f2ede1f4', 'vpc_id': 'vpc-06e13c7cdf3e917f5', 'interface_type': 'interface'}], 'root_device_name': '/dev/xvda', 'root_device_type': 'ebs', 'security_groups': [{'group_name': 'Freedom', 'group_id': 'sg-09a5a43f8400c81c4'}], 'source_dest_check': True, 'tags': {'Name': 'Zomato-webserver', 'Env': 'Dev', 'Project': 'Zomato', 'aws:autoscaling:groupName': 'shopping-asg', 'aws:ec2launchtemplate:id': 'lt-0acf1324f7d389679', 'aws:ec2launchtemplate:version': '1'}, 'virtualization_type': 'hvm', 'cpu_options': {'core_count': 1, 'threads_per_core': 1}, 'capacity_reservation_specification': {'capacity_reservation_preference': 'open'}, 'hibernation_options': {'configured': False}, 'metadata_options': {'state': 'applied', 'http_tokens': 'required', 'http_put_response_hop_limit': 2, 'http_endpoint': 'enabled', 'http_protocol_ipv6': 'disabled', 'instance_metadata_tags': 'disabled'}, 'enclave_options': {'enabled': False}, 'boot_mode': 'uefi-preferred', 'platform_details': 'Linux/UNIX', 'usage_operation': 'RunInstances', 'usage_operation_update_time': '2023-07-01T11:11:36+00:00', 'private_dns_name_options': {'hostname_type': 'ip-name', 'enable_resource_name_dns_a_record': False, 'enable_resource_name_dns_aaaa_record': False}, 'maintenance_options': {'auto_recovery': 'default'}, 'current_instance_boot_mode': 'legacy-bios'})
  343. changed: [localhost] => (item={'ami_launch_index': 0, 'image_id': 'ami-0b9ecf71fe947bbdd', 'instance_id': 'i-0ac06441ba2439468', 'instance_type': 't2.micro', 'key_name': 'mumbai-new', 'launch_time': '2023-07-01T11:11:36+00:00', 'monitoring': {'state': 'disabled'}, 'placement': {'availability_zone': 'ap-south-1a', 'group_name': '', 'tenancy': 'default'}, 'private_dns_name': 'ip-172-31-40-50.ap-south-1.compute.internal', 'private_ip_address': '172.31.40.50', 'product_codes': [], 'public_dns_name': 'ec2-35-154-112-147.ap-south-1.compute.amazonaws.com', 'public_ip_address': '35.154.112.147', 'state': {'code': 16, 'name': 'running'}, 'state_transition_reason': '', 'subnet_id': 'subnet-03d5cac27f2ede1f4', 'vpc_id': 'vpc-06e13c7cdf3e917f5', 'architecture': 'x86_64', 'block_device_mappings': [{'device_name': '/dev/xvda', 'ebs': {'attach_time': '2023-07-01T11:11:37+00:00', 'delete_on_termination': True, 'status': 'attached', 'volume_id': 'vol-022067d2a2c37d3b1'}}], 'client_token': 'ef762444-9ac3-8fd3-f62d-c81f56de514d', 'ebs_optimized': False, 'ena_support': True, 'hypervisor': 'xen', 'network_interfaces': [{'association': {'ip_owner_id': 'amazon', 'public_dns_name': 'ec2-35-154-112-147.ap-south-1.compute.amazonaws.com', 'public_ip': '35.154.112.147'}, 'attachment': {'attach_time': '2023-07-01T11:11:36+00:00', 'attachment_id': 'eni-attach-0e4b82096408ffd6e', 'delete_on_termination': True, 'device_index': 0, 'status': 'attached', 'network_card_index': 0}, 'description': '', 'groups': [{'group_name': 'Freedom', 'group_id': 'sg-09a5a43f8400c81c4'}], 'ipv6_addresses': [], 'mac_address': '02:90:41:bb:ba:8e', 'network_interface_id': 'eni-00a5fe13f3a812d26', 'owner_id': '945577359662', 'private_dns_name': 'ip-172-31-40-50.ap-south-1.compute.internal', 'private_ip_address': '172.31.40.50', 'private_ip_addresses': [{'association': {'ip_owner_id': 'amazon', 'public_dns_name': 'ec2-35-154-112-147.ap-south-1.compute.amazonaws.com', 'public_ip': '35.154.112.147'}, 'primary': True, 'private_dns_name': 'ip-172-31-40-50.ap-south-1.compute.internal', 'private_ip_address': '172.31.40.50'}], 'source_dest_check': True, 'status': 'in-use', 'subnet_id': 'subnet-03d5cac27f2ede1f4', 'vpc_id': 'vpc-06e13c7cdf3e917f5', 'interface_type': 'interface'}], 'root_device_name': '/dev/xvda', 'root_device_type': 'ebs', 'security_groups': [{'group_name': 'Freedom', 'group_id': 'sg-09a5a43f8400c81c4'}], 'source_dest_check': True, 'tags': {'aws:ec2launchtemplate:version': '1', 'Name': 'Zomato-webserver', 'aws:ec2launchtemplate:id': 'lt-0acf1324f7d389679', 'aws:autoscaling:groupName': 'shopping-asg', 'Env': 'Dev', 'Project': 'Zomato'}, 'virtualization_type': 'hvm', 'cpu_options': {'core_count': 1, 'threads_per_core': 1}, 'capacity_reservation_specification': {'capacity_reservation_preference': 'open'}, 'hibernation_options': {'configured': False}, 'metadata_options': {'state': 'applied', 'http_tokens': 'required', 'http_put_response_hop_limit': 2, 'http_endpoint': 'enabled', 'http_protocol_ipv6': 'disabled', 'instance_metadata_tags': 'disabled'}, 'enclave_options': {'enabled': False}, 'boot_mode': 'uefi-preferred', 'platform_details': 'Linux/UNIX', 'usage_operation': 'RunInstances', 'usage_operation_update_time': '2023-07-01T11:11:36+00:00', 'private_dns_name_options': {'hostname_type': 'ip-name', 'enable_resource_name_dns_a_record': False, 'enable_resource_name_dns_aaaa_record': False}, 'maintenance_options': {'auto_recovery': 'default'}, 'current_instance_boot_mode': 'legacy-bios'})
  344. changed: [localhost] => (item={'ami_launch_index': 0, 'image_id': 'ami-0b9ecf71fe947bbdd', 'instance_id': 'i-0b4761ec172352872', 'instance_type': 't2.micro', 'key_name': 'mumbai-new', 'launch_time': '2023-07-01T11:11:36+00:00', 'monitoring': {'state': 'disabled'}, 'placement': {'availability_zone': 'ap-south-1b', 'group_name': '', 'tenancy': 'default'}, 'private_dns_name': 'ip-172-31-2-19.ap-south-1.compute.internal', 'private_ip_address': '172.31.2.19', 'product_codes': [], 'public_dns_name': 'ec2-65-0-87-36.ap-south-1.compute.amazonaws.com', 'public_ip_address': '65.0.87.36', 'state': {'code': 16, 'name': 'running'}, 'state_transition_reason': '', 'subnet_id': 'subnet-0c662917265d9d0e9', 'vpc_id': 'vpc-06e13c7cdf3e917f5', 'architecture': 'x86_64', 'block_device_mappings': [{'device_name': '/dev/xvda', 'ebs': {'attach_time': '2023-07-01T11:11:37+00:00', 'delete_on_termination': True, 'status': 'attached', 'volume_id': 'vol-0dd243cd99ffbc8ba'}}], 'client_token': '46862444-9ac2-9a4e-f074-06936da27bb3', 'ebs_optimized': False, 'ena_support': True, 'hypervisor': 'xen', 'network_interfaces': [{'association': {'ip_owner_id': 'amazon', 'public_dns_name': 'ec2-65-0-87-36.ap-south-1.compute.amazonaws.com', 'public_ip': '65.0.87.36'}, 'attachment': {'attach_time': '2023-07-01T11:11:36+00:00', 'attachment_id': 'eni-attach-013c3173b26695722', 'delete_on_termination': True, 'device_index': 0, 'status': 'attached', 'network_card_index': 0}, 'description': '', 'groups': [{'group_name': 'Freedom', 'group_id': 'sg-09a5a43f8400c81c4'}], 'ipv6_addresses': [], 'mac_address': '0a:ea:d0:e7:b0:54', 'network_interface_id': 'eni-059263a4b61df6a21', 'owner_id': '945577359662', 'private_dns_name': 'ip-172-31-2-19.ap-south-1.compute.internal', 'private_ip_address': '172.31.2.19', 'private_ip_addresses': [{'association': {'ip_owner_id': 'amazon', 'public_dns_name': 'ec2-65-0-87-36.ap-south-1.compute.amazonaws.com', 'public_ip': '65.0.87.36'}, 'primary': True, 'private_dns_name': 'ip-172-31-2-19.ap-south-1.compute.internal', 'private_ip_address': '172.31.2.19'}], 'source_dest_check': True, 'status': 'in-use', 'subnet_id': 'subnet-0c662917265d9d0e9', 'vpc_id': 'vpc-06e13c7cdf3e917f5', 'interface_type': 'interface'}], 'root_device_name': '/dev/xvda', 'root_device_type': 'ebs', 'security_groups': [{'group_name': 'Freedom', 'group_id': 'sg-09a5a43f8400c81c4'}], 'source_dest_check': True, 'tags': {'Env': 'Dev', 'aws:ec2launchtemplate:version': '1', 'aws:ec2launchtemplate:id': 'lt-0acf1324f7d389679', 'Project': 'Zomato', 'aws:autoscaling:groupName': 'shopping-asg', 'Name': 'Zomato-webserver'}, 'virtualization_type': 'hvm', 'cpu_options': {'core_count': 1, 'threads_per_core': 1}, 'capacity_reservation_specification': {'capacity_reservation_preference': 'open'}, 'hibernation_options': {'configured': False}, 'metadata_options': {'state': 'applied', 'http_tokens': 'required', 'http_put_response_hop_limit': 2, 'http_endpoint': 'enabled', 'http_protocol_ipv6': 'disabled', 'instance_metadata_tags': 'disabled'}, 'enclave_options': {'enabled': False}, 'boot_mode': 'uefi-preferred', 'platform_details': 'Linux/UNIX', 'usage_operation': 'RunInstances', 'usage_operation_update_time': '2023-07-01T11:11:36+00:00', 'private_dns_name_options': {'hostname_type': 'ip-name', 'enable_resource_name_dns_a_record': False, 'enable_resource_name_dns_aaaa_record': False}, 'maintenance_options': {'auto_recovery': 'default'}, 'current_instance_boot_mode': 'legacy-bios'})
  345.  
  346. PLAY [Rolling update] **************************************************************************************************
  347.  
  348. TASK [Gathering Facts] *************************************************************************************************
  349. ok: [172.31.45.142]
  350.  
  351. TASK [Installing required packages] ************************************************************************************
  352. ok: [172.31.45.142]
  353.  
  354. TASK [Cloning the git rep to /var/website/] ****************************************************************************
  355. changed: [172.31.45.142]
  356.  
  357. TASK [Draining the clb] ************************************************************************************************
  358. changed: [172.31.45.142]
  359.  
  360. TASK [Making sure the connection draining time interval is matched] ****************************************************
  361. ok: [172.31.45.142]
  362.  
  363. TASK [Copying the website to docroot] **********************************************************************************
  364. changed: [172.31.45.142]
  365.  
  366. TASK [Attaching it to clb] *********************************************************************************************
  367. changed: [172.31.45.142]
  368.  
  369. TASK [Healthy status in-service] ***************************************************************************************
  370. ok: [172.31.45.142]
  371.  
  372. PLAY [Rolling update] **************************************************************************************************
  373.  
  374. TASK [Gathering Facts] *************************************************************************************************
  375. ok: [172.31.40.50]
  376.  
  377. TASK [Installing required packages] ************************************************************************************
  378. ok: [172.31.40.50]
  379.  
  380. TASK [Cloning the git rep to /var/website/] ****************************************************************************
  381. changed: [172.31.40.50]
  382.  
  383. TASK [Draining the clb] ************************************************************************************************
  384. changed: [172.31.40.50]
  385.  
  386. TASK [Making sure the connection draining time interval is matched] ****************************************************
  387. ok: [172.31.40.50]
  388.  
  389. TASK [Copying the website to docroot] **********************************************************************************
  390. changed: [172.31.40.50]
  391.  
  392. TASK [Attaching it to clb] *********************************************************************************************
  393. changed: [172.31.40.50]
  394.  
  395. TASK [Healthy status in-service] ***************************************************************************************
  396. ok: [172.31.40.50]
  397.  
  398. PLAY [Rolling update] **************************************************************************************************
  399.  
  400. TASK [Gathering Facts] *************************************************************************************************
  401. ok: [172.31.2.19]
  402.  
  403. TASK [Installing required packages] ************************************************************************************
  404. ok: [172.31.2.19]
  405.  
  406. TASK [Cloning the git rep to /var/website/] ****************************************************************************
  407. changed: [172.31.2.19]
  408.  
  409. TASK [Draining the clb] ************************************************************************************************
  410. changed: [172.31.2.19]
  411.  
  412. TASK [Making sure the connection draining time interval is matched] ****************************************************
  413. ok: [172.31.2.19]
  414.  
  415. TASK [Copying the website to docroot] **********************************************************************************
  416. changed: [172.31.2.19]
  417.  
  418. TASK [Attaching it to clb] *********************************************************************************************
  419. changed: [172.31.2.19]
  420.  
  421. TASK [Healthy status in-service] ***************************************************************************************
  422. ok: [172.31.2.19]
  423.  
  424. PLAY RECAP *************************************************************************************************************
  425. 172.31.2.19                : ok=8    changed=4    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
  426. 172.31.40.50               : ok=8    changed=4    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
  427. 172.31.45.142              : ok=8    changed=4    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
  428. localhost                  : ok=6    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
  429.  
  430.  
  431.  
  432.  
  433.  
  434. --------------------------------- Task 2 Installing package if not found ---------------
  435.  
  436.  
  437. #### Playbook ####
  438.  
  439.  
  440. - name: "Checking the package docker installed in remote_server"
  441.   hosts: Zomato-infra
  442.   become: true
  443.   tasks:
  444.     - name: "Checking through package_facts"
  445.       package_facts:
  446.          manager: auto
  447.       tags:
  448.        - zomato
  449.     - name: "Checking docker installed on remote servers"
  450.       debug:
  451.         msg: "{{ ansible_facts.packages.httpd }} is installed or not!"
  452.       ignore_errors: true
  453.       register: httpd_status
  454.       tags: zomato
  455.  
  456.     - name: "Printing the 2nd register"
  457.       debug:
  458.         var: httpd_status
  459.       tags: zomato
  460.     - name: "Install the package if not found in remote server"
  461.       when: httpd_status.failed == true
  462.       shell: yum install httpd -y
  463.       tags: zomato
  464.  
  465.  
  466.  
  467.  
  468.  
  469. #### Output #####
  470.  
  471.  
  472. [ec2-user@ip-172-31-6-232 ~]$ ansible-playbook aws.yml --vault-password-file=passwd.sh -t zomato
  473. [WARNING]: No inventory was parsed, only implicit localhost is available
  474. [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match
  475. 'all'
  476.  
  477. PLAY [Creating a dynamic inventory for Zomato-infra] *******************************************************************
  478.  
  479. TASK [Gathering Facts] *************************************************************************************************
  480. ok: [localhost]
  481.  
  482. TASK [Collect aws ec2-instance info of zomato-infra] *******************************************************************
  483. ok: [localhost]
  484.  
  485. TASK [Creating a dynamic inventory] ************************************************************************************
  486. [WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details
  487. changed: [localhost] => (item={'ami_launch_index': 1, 'image_id': 'ami-0b9ecf71fe947bbdd', 'instance_id': 'i-008fc4bdb8ba86fb3', 'instance_type': 't2.micro', 'key_name': 'mumbai-new', 'launch_time': '2023-07-01T11:11:36+00:00', 'monitoring': {'state': 'disabled'}, 'placement': {'availability_zone': 'ap-south-1a', 'group_name': '', 'tenancy': 'default'}, 'private_dns_name': 'ip-172-31-45-142.ap-south-1.compute.internal', 'private_ip_address': '172.31.45.142', 'product_codes': [], 'public_dns_name': 'ec2-13-127-88-76.ap-south-1.compute.amazonaws.com', 'public_ip_address': '13.127.88.76', 'state': {'code': 16, 'name': 'running'}, 'state_transition_reason': '', 'subnet_id': 'subnet-03d5cac27f2ede1f4', 'vpc_id': 'vpc-06e13c7cdf3e917f5', 'architecture': 'x86_64', 'block_device_mappings': [{'device_name': '/dev/xvda', 'ebs': {'attach_time': '2023-07-01T11:11:37+00:00', 'delete_on_termination': True, 'status': 'attached', 'volume_id': 'vol-0d60b31054268e467'}}], 'client_token': 'ef762444-9ac3-8fd3-f62d-c81f56de514d', 'ebs_optimized': False, 'ena_support': True, 'hypervisor': 'xen', 'network_interfaces': [{'association': {'ip_owner_id': 'amazon', 'public_dns_name': 'ec2-13-127-88-76.ap-south-1.compute.amazonaws.com', 'public_ip': '13.127.88.76'}, 'attachment': {'attach_time': '2023-07-01T11:11:36+00:00', 'attachment_id': 'eni-attach-066ae20667796d516', 'delete_on_termination': True, 'device_index': 0, 'status': 'attached', 'network_card_index': 0}, 'description': '', 'groups': [{'group_name': 'Freedom', 'group_id': 'sg-09a5a43f8400c81c4'}], 'ipv6_addresses': [], 'mac_address': '02:e2:19:35:2f:64', 'network_interface_id': 'eni-0002514e9fdfeb2ef', 'owner_id': '945577359662', 'private_dns_name': 'ip-172-31-45-142.ap-south-1.compute.internal', 'private_ip_address': '172.31.45.142', 'private_ip_addresses': [{'association': {'ip_owner_id': 'amazon', 'public_dns_name': 'ec2-13-127-88-76.ap-south-1.compute.amazonaws.com', 'public_ip': '13.127.88.76'}, 'primary': True, 'private_dns_name': 'ip-172-31-45-142.ap-south-1.compute.internal', 'private_ip_address': '172.31.45.142'}], 'source_dest_check': True, 'status': 'in-use', 'subnet_id': 'subnet-03d5cac27f2ede1f4', 'vpc_id': 'vpc-06e13c7cdf3e917f5', 'interface_type': 'interface'}], 'root_device_name': '/dev/xvda', 'root_device_type': 'ebs', 'security_groups': [{'group_name': 'Freedom', 'group_id': 'sg-09a5a43f8400c81c4'}], 'source_dest_check': True, 'tags': {'Name': 'Zomato-webserver', 'Env': 'Dev', 'Project': 'Zomato', 'aws:autoscaling:groupName': 'shopping-asg', 'aws:ec2launchtemplate:id': 'lt-0acf1324f7d389679', 'aws:ec2launchtemplate:version': '1'}, 'virtualization_type': 'hvm', 'cpu_options': {'core_count': 1, 'threads_per_core': 1}, 'capacity_reservation_specification': {'capacity_reservation_preference': 'open'}, 'hibernation_options': {'configured': False}, 'metadata_options': {'state': 'applied', 'http_tokens': 'required', 'http_put_response_hop_limit': 2, 'http_endpoint': 'enabled', 'http_protocol_ipv6': 'disabled', 'instance_metadata_tags': 'disabled'}, 'enclave_options': {'enabled': False}, 'boot_mode': 'uefi-preferred', 'platform_details': 'Linux/UNIX', 'usage_operation': 'RunInstances', 'usage_operation_update_time': '2023-07-01T11:11:36+00:00', 'private_dns_name_options': {'hostname_type': 'ip-name', 'enable_resource_name_dns_a_record': False, 'enable_resource_name_dns_aaaa_record': False}, 'maintenance_options': {'auto_recovery': 'default'}, 'current_instance_boot_mode': 'legacy-bios'})
  488. changed: [localhost] => (item={'ami_launch_index': 0, 'image_id': 'ami-0b9ecf71fe947bbdd', 'instance_id': 'i-0ac06441ba2439468', 'instance_type': 't2.micro', 'key_name': 'mumbai-new', 'launch_time': '2023-07-01T11:11:36+00:00', 'monitoring': {'state': 'disabled'}, 'placement': {'availability_zone': 'ap-south-1a', 'group_name': '', 'tenancy': 'default'}, 'private_dns_name': 'ip-172-31-40-50.ap-south-1.compute.internal', 'private_ip_address': '172.31.40.50', 'product_codes': [], 'public_dns_name': 'ec2-35-154-112-147.ap-south-1.compute.amazonaws.com', 'public_ip_address': '35.154.112.147', 'state': {'code': 16, 'name': 'running'}, 'state_transition_reason': '', 'subnet_id': 'subnet-03d5cac27f2ede1f4', 'vpc_id': 'vpc-06e13c7cdf3e917f5', 'architecture': 'x86_64', 'block_device_mappings': [{'device_name': '/dev/xvda', 'ebs': {'attach_time': '2023-07-01T11:11:37+00:00', 'delete_on_termination': True, 'status': 'attached', 'volume_id': 'vol-022067d2a2c37d3b1'}}], 'client_token': 'ef762444-9ac3-8fd3-f62d-c81f56de514d', 'ebs_optimized': False, 'ena_support': True, 'hypervisor': 'xen', 'network_interfaces': [{'association': {'ip_owner_id': 'amazon', 'public_dns_name': 'ec2-35-154-112-147.ap-south-1.compute.amazonaws.com', 'public_ip': '35.154.112.147'}, 'attachment': {'attach_time': '2023-07-01T11:11:36+00:00', 'attachment_id': 'eni-attach-0e4b82096408ffd6e', 'delete_on_termination': True, 'device_index': 0, 'status': 'attached', 'network_card_index': 0}, 'description': '', 'groups': [{'group_name': 'Freedom', 'group_id': 'sg-09a5a43f8400c81c4'}], 'ipv6_addresses': [], 'mac_address': '02:90:41:bb:ba:8e', 'network_interface_id': 'eni-00a5fe13f3a812d26', 'owner_id': '945577359662', 'private_dns_name': 'ip-172-31-40-50.ap-south-1.compute.internal', 'private_ip_address': '172.31.40.50', 'private_ip_addresses': [{'association': {'ip_owner_id': 'amazon', 'public_dns_name': 'ec2-35-154-112-147.ap-south-1.compute.amazonaws.com', 'public_ip': '35.154.112.147'}, 'primary': True, 'private_dns_name': 'ip-172-31-40-50.ap-south-1.compute.internal', 'private_ip_address': '172.31.40.50'}], 'source_dest_check': True, 'status': 'in-use', 'subnet_id': 'subnet-03d5cac27f2ede1f4', 'vpc_id': 'vpc-06e13c7cdf3e917f5', 'interface_type': 'interface'}], 'root_device_name': '/dev/xvda', 'root_device_type': 'ebs', 'security_groups': [{'group_name': 'Freedom', 'group_id': 'sg-09a5a43f8400c81c4'}], 'source_dest_check': True, 'tags': {'aws:ec2launchtemplate:version': '1', 'Name': 'Zomato-webserver', 'aws:ec2launchtemplate:id': 'lt-0acf1324f7d389679', 'aws:autoscaling:groupName': 'shopping-asg', 'Env': 'Dev', 'Project': 'Zomato'}, 'virtualization_type': 'hvm', 'cpu_options': {'core_count': 1, 'threads_per_core': 1}, 'capacity_reservation_specification': {'capacity_reservation_preference': 'open'}, 'hibernation_options': {'configured': False}, 'metadata_options': {'state': 'applied', 'http_tokens': 'required', 'http_put_response_hop_limit': 2, 'http_endpoint': 'enabled', 'http_protocol_ipv6': 'disabled', 'instance_metadata_tags': 'disabled'}, 'enclave_options': {'enabled': False}, 'boot_mode': 'uefi-preferred', 'platform_details': 'Linux/UNIX', 'usage_operation': 'RunInstances', 'usage_operation_update_time': '2023-07-01T11:11:36+00:00', 'private_dns_name_options': {'hostname_type': 'ip-name', 'enable_resource_name_dns_a_record': False, 'enable_resource_name_dns_aaaa_record': False}, 'maintenance_options': {'auto_recovery': 'default'}, 'current_instance_boot_mode': 'legacy-bios'})
  489. changed: [localhost] => (item={'ami_launch_index': 0, 'image_id': 'ami-0b9ecf71fe947bbdd', 'instance_id': 'i-0b4761ec172352872', 'instance_type': 't2.micro', 'key_name': 'mumbai-new', 'launch_time': '2023-07-01T11:11:36+00:00', 'monitoring': {'state': 'disabled'}, 'placement': {'availability_zone': 'ap-south-1b', 'group_name': '', 'tenancy': 'default'}, 'private_dns_name': 'ip-172-31-2-19.ap-south-1.compute.internal', 'private_ip_address': '172.31.2.19', 'product_codes': [], 'public_dns_name': 'ec2-65-0-87-36.ap-south-1.compute.amazonaws.com', 'public_ip_address': '65.0.87.36', 'state': {'code': 16, 'name': 'running'}, 'state_transition_reason': '', 'subnet_id': 'subnet-0c662917265d9d0e9', 'vpc_id': 'vpc-06e13c7cdf3e917f5', 'architecture': 'x86_64', 'block_device_mappings': [{'device_name': '/dev/xvda', 'ebs': {'attach_time': '2023-07-01T11:11:37+00:00', 'delete_on_termination': True, 'status': 'attached', 'volume_id': 'vol-0dd243cd99ffbc8ba'}}], 'client_token': '46862444-9ac2-9a4e-f074-06936da27bb3', 'ebs_optimized': False, 'ena_support': True, 'hypervisor': 'xen', 'network_interfaces': [{'association': {'ip_owner_id': 'amazon', 'public_dns_name': 'ec2-65-0-87-36.ap-south-1.compute.amazonaws.com', 'public_ip': '65.0.87.36'}, 'attachment': {'attach_time': '2023-07-01T11:11:36+00:00', 'attachment_id': 'eni-attach-013c3173b26695722', 'delete_on_termination': True, 'device_index': 0, 'status': 'attached', 'network_card_index': 0}, 'description': '', 'groups': [{'group_name': 'Freedom', 'group_id': 'sg-09a5a43f8400c81c4'}], 'ipv6_addresses': [], 'mac_address': '0a:ea:d0:e7:b0:54', 'network_interface_id': 'eni-059263a4b61df6a21', 'owner_id': '945577359662', 'private_dns_name': 'ip-172-31-2-19.ap-south-1.compute.internal', 'private_ip_address': '172.31.2.19', 'private_ip_addresses': [{'association': {'ip_owner_id': 'amazon', 'public_dns_name': 'ec2-65-0-87-36.ap-south-1.compute.amazonaws.com', 'public_ip': '65.0.87.36'}, 'primary': True, 'private_dns_name': 'ip-172-31-2-19.ap-south-1.compute.internal', 'private_ip_address': '172.31.2.19'}], 'source_dest_check': True, 'status': 'in-use', 'subnet_id': 'subnet-0c662917265d9d0e9', 'vpc_id': 'vpc-06e13c7cdf3e917f5', 'interface_type': 'interface'}], 'root_device_name': '/dev/xvda', 'root_device_type': 'ebs', 'security_groups': [{'group_name': 'Freedom', 'group_id': 'sg-09a5a43f8400c81c4'}], 'source_dest_check': True, 'tags': {'Env': 'Dev', 'aws:ec2launchtemplate:version': '1', 'aws:ec2launchtemplate:id': 'lt-0acf1324f7d389679', 'Project': 'Zomato', 'aws:autoscaling:groupName': 'shopping-asg', 'Name': 'Zomato-webserver'}, 'virtualization_type': 'hvm', 'cpu_options': {'core_count': 1, 'threads_per_core': 1}, 'capacity_reservation_specification': {'capacity_reservation_preference': 'open'}, 'hibernation_options': {'configured': False}, 'metadata_options': {'state': 'applied', 'http_tokens': 'required', 'http_put_response_hop_limit': 2, 'http_endpoint': 'enabled', 'http_protocol_ipv6': 'disabled', 'instance_metadata_tags': 'disabled'}, 'enclave_options': {'enabled': False}, 'boot_mode': 'uefi-preferred', 'platform_details': 'Linux/UNIX', 'usage_operation': 'RunInstances', 'usage_operation_update_time': '2023-07-01T11:11:36+00:00', 'private_dns_name_options': {'hostname_type': 'ip-name', 'enable_resource_name_dns_a_record': False, 'enable_resource_name_dns_aaaa_record': False}, 'maintenance_options': {'auto_recovery': 'default'}, 'current_instance_boot_mode': 'legacy-bios'})
  490.  
  491. PLAY [Rolling update] **************************************************************************************************
  492.  
  493. TASK [Gathering Facts] *************************************************************************************************
  494. ok: [172.31.45.142]
  495.  
  496. PLAY [Rolling update] **************************************************************************************************
  497.  
  498. TASK [Gathering Facts] *************************************************************************************************
  499. ok: [172.31.40.50]
  500.  
  501. PLAY [Rolling update] **************************************************************************************************
  502.  
  503. TASK [Gathering Facts] *************************************************************************************************
  504. ok: [172.31.2.19]
  505.  
  506. PLAY [Checking the package docker installed in remote_server] **********************************************************
  507.  
  508. TASK [Gathering Facts] *************************************************************************************************
  509. ok: [172.31.40.50]
  510. ok: [172.31.2.19]
  511. ok: [172.31.45.142]
  512.  
  513. TASK [Checking through package_facts] **********************************************************************************
  514. ok: [172.31.45.142]
  515. ok: [172.31.40.50]
  516. ok: [172.31.2.19]
  517.  
  518. TASK [Checking docker installed on remote servers] *********************************************************************
  519. ok: [172.31.45.142] => {
  520.     "msg": "[{'name': 'httpd', 'version': '2.4.56', 'release': '1.amzn2023', 'epoch': None, 'arch': 'x86_64', 'source': 'rpm'}] is installed or not!"
  521. }
  522. ok: [172.31.40.50] => {
  523.     "msg": "[{'name': 'httpd', 'version': '2.4.56', 'release': '1.amzn2023', 'epoch': None, 'arch': 'x86_64', 'source': 'rpm'}] is installed or not!"
  524. }
  525. ok: [172.31.2.19] => {
  526.     "msg": "[{'name': 'httpd', 'version': '2.4.56', 'release': '1.amzn2023', 'epoch': None, 'arch': 'x86_64', 'source': 'rpm'}] is installed or not!"
  527. }
  528.  
  529. TASK [Printing the 2nd register] ***************************************************************************************
  530. ok: [172.31.45.142] => {
  531.     "httpd_status": {
  532.         "changed": false,
  533.         "failed": false,
  534.         "msg": "[{'name': 'httpd', 'version': '2.4.56', 'release': '1.amzn2023', 'epoch': None, 'arch': 'x86_64', 'source': 'rpm'}] is installed or not!"
  535.     }
  536. }
  537. ok: [172.31.40.50] => {
  538.     "httpd_status": {
  539.         "changed": false,
  540.         "failed": false,
  541.         "msg": "[{'name': 'httpd', 'version': '2.4.56', 'release': '1.amzn2023', 'epoch': None, 'arch': 'x86_64', 'source': 'rpm'}] is installed or not!"
  542.     }
  543. }
  544. ok: [172.31.2.19] => {
  545.     "httpd_status": {
  546.         "changed": false,
  547.         "failed": false,
  548.         "msg": "[{'name': 'httpd', 'version': '2.4.56', 'release': '1.amzn2023', 'epoch': None, 'arch': 'x86_64', 'source': 'rpm'}] is installed or not!"
  549.     }
  550. }
  551.  
  552. TASK [Install the package if not found in remote server] ***************************************************************
  553. skipping: [172.31.45.142]
  554. skipping: [172.31.40.50]
  555. skipping: [172.31.2.19]
  556.  
  557. PLAY RECAP *************************************************************************************************************
  558. 172.31.2.19                : ok=5    changed=0    unreachable=0    failed=0    skipped=1    rescued=0    ignored=0
  559. 172.31.40.50               : ok=5    changed=0    unreachable=0    failed=0    skipped=1    rescued=0    ignored=0
  560. 172.31.45.142              : ok=5    changed=0    unreachable=0    failed=0    skipped=1    rescued=0    ignored=0
  561. localhost                  : ok=3    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
  562.  
  563.  
  564.  
  565.  
  566. #### Installing package docker ####
  567.  
  568.  
  569.  
  570. [ec2-user@ip-172-31-6-232 ~]$ ansible-playbook aws.yml --vault-password-file=passwd.sh -t zomato
  571.  
  572.  
  573. PLAY [Creating a dynamic inventory for Zomato-infra] *******************************************************************
  574.  
  575. TASK [Gathering Facts] *************************************************************************************************
  576. ok: [localhost]
  577.  
  578. TASK [Collect aws ec2-instance info of zomato-infra] *******************************************************************
  579. ok: [localhost]
  580.  
  581. TASK [Creating a dynamic inventory] ************************************************************************************
  582. [WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details
  583. changed: [localhost] => (item={'ami_launch_index': 1, 'image_id': 'ami-0b9ecf71fe947bbdd', 'instance_id': 'i-008fc4bdb8ba86fb3', 'instance_type': 't2.micro', 'key_name': 'mumbai-new', 'launch_time': '2023-07-01T11:11:36+00:00', 'monitoring': {'state': 'disabled'}, 'placement': {'availability_zone': 'ap-south-1a', 'group_name': '', 'tenancy': 'default'}, 'private_dns_name': 'ip-172-31-45-142.ap-south-1.compute.internal', 'private_ip_address': '172.31.45.142', 'product_codes': [], 'public_dns_name': 'ec2-13-127-88-76.ap-south-1.compute.amazonaws.com', 'public_ip_address': '13.127.88.76', 'state': {'code': 16, 'name': 'running'}, 'state_transition_reason': '', 'subnet_id': 'subnet-03d5cac27f2ede1f4', 'vpc_id': 'vpc-06e13c7cdf3e917f5', 'architecture': 'x86_64', 'block_device_mappings': [{'device_name': '/dev/xvda', 'ebs': {'attach_time': '2023-07-01T11:11:37+00:00', 'delete_on_termination': True, 'status': 'attached', 'volume_id': 'vol-0d60b31054268e467'}}], 'client_token': 'ef762444-9ac3-8fd3-f62d-c81f56de514d', 'ebs_optimized': False, 'ena_support': True, 'hypervisor': 'xen', 'network_interfaces': [{'association': {'ip_owner_id': 'amazon', 'public_dns_name': 'ec2-13-127-88-76.ap-south-1.compute.amazonaws.com', 'public_ip': '13.127.88.76'}, 'attachment': {'attach_time': '2023-07-01T11:11:36+00:00', 'attachment_id': 'eni-attach-066ae20667796d516', 'delete_on_termination': True, 'device_index': 0, 'status': 'attached', 'network_card_index': 0}, 'description': '', 'groups': [{'group_name': 'Freedom', 'group_id': 'sg-09a5a43f8400c81c4'}], 'ipv6_addresses': [], 'mac_address': '02:e2:19:35:2f:64', 'network_interface_id': 'eni-0002514e9fdfeb2ef', 'owner_id': '945577359662', 'private_dns_name': 'ip-172-31-45-142.ap-south-1.compute.internal', 'private_ip_address': '172.31.45.142', 'private_ip_addresses': [{'association': {'ip_owner_id': 'amazon', 'public_dns_name': 'ec2-13-127-88-76.ap-south-1.compute.amazonaws.com', 'public_ip': '13.127.88.76'}, 'primary': True, 'private_dns_name': 'ip-172-31-45-142.ap-south-1.compute.internal', 'private_ip_address': '172.31.45.142'}], 'source_dest_check': True, 'status': 'in-use', 'subnet_id': 'subnet-03d5cac27f2ede1f4', 'vpc_id': 'vpc-06e13c7cdf3e917f5', 'interface_type': 'interface'}], 'root_device_name': '/dev/xvda', 'root_device_type': 'ebs', 'security_groups': [{'group_name': 'Freedom', 'group_id': 'sg-09a5a43f8400c81c4'}], 'source_dest_check': True, 'tags': {'Name': 'Zomato-webserver', 'Env': 'Dev', 'Project': 'Zomato', 'aws:autoscaling:groupName': 'shopping-asg', 'aws:ec2launchtemplate:id': 'lt-0acf1324f7d389679', 'aws:ec2launchtemplate:version': '1'}, 'virtualization_type': 'hvm', 'cpu_options': {'core_count': 1, 'threads_per_core': 1}, 'capacity_reservation_specification': {'capacity_reservation_preference': 'open'}, 'hibernation_options': {'configured': False}, 'metadata_options': {'state': 'applied', 'http_tokens': 'required', 'http_put_response_hop_limit': 2, 'http_endpoint': 'enabled', 'http_protocol_ipv6': 'disabled', 'instance_metadata_tags': 'disabled'}, 'enclave_options': {'enabled': False}, 'boot_mode': 'uefi-preferred', 'platform_details': 'Linux/UNIX', 'usage_operation': 'RunInstances', 'usage_operation_update_time': '2023-07-01T11:11:36+00:00', 'private_dns_name_options': {'hostname_type': 'ip-name', 'enable_resource_name_dns_a_record': False, 'enable_resource_name_dns_aaaa_record': False}, 'maintenance_options': {'auto_recovery': 'default'}, 'current_instance_boot_mode': 'legacy-bios'})
  584. changed: [localhost] => (item={'ami_launch_index': 0, 'image_id': 'ami-0b9ecf71fe947bbdd', 'instance_id': 'i-0ac06441ba2439468', 'instance_type': 't2.micro', 'key_name': 'mumbai-new', 'launch_time': '2023-07-01T11:11:36+00:00', 'monitoring': {'state': 'disabled'}, 'placement': {'availability_zone': 'ap-south-1a', 'group_name': '', 'tenancy': 'default'}, 'private_dns_name': 'ip-172-31-40-50.ap-south-1.compute.internal', 'private_ip_address': '172.31.40.50', 'product_codes': [], 'public_dns_name': 'ec2-35-154-112-147.ap-south-1.compute.amazonaws.com', 'public_ip_address': '35.154.112.147', 'state': {'code': 16, 'name': 'running'}, 'state_transition_reason': '', 'subnet_id': 'subnet-03d5cac27f2ede1f4', 'vpc_id': 'vpc-06e13c7cdf3e917f5', 'architecture': 'x86_64', 'block_device_mappings': [{'device_name': '/dev/xvda', 'ebs': {'attach_time': '2023-07-01T11:11:37+00:00', 'delete_on_termination': True, 'status': 'attached', 'volume_id': 'vol-022067d2a2c37d3b1'}}], 'client_token': 'ef762444-9ac3-8fd3-f62d-c81f56de514d', 'ebs_optimized': False, 'ena_support': True, 'hypervisor': 'xen', 'network_interfaces': [{'association': {'ip_owner_id': 'amazon', 'public_dns_name': 'ec2-35-154-112-147.ap-south-1.compute.amazonaws.com', 'public_ip': '35.154.112.147'}, 'attachment': {'attach_time': '2023-07-01T11:11:36+00:00', 'attachment_id': 'eni-attach-0e4b82096408ffd6e', 'delete_on_termination': True, 'device_index': 0, 'status': 'attached', 'network_card_index': 0}, 'description': '', 'groups': [{'group_name': 'Freedom', 'group_id': 'sg-09a5a43f8400c81c4'}], 'ipv6_addresses': [], 'mac_address': '02:90:41:bb:ba:8e', 'network_interface_id': 'eni-00a5fe13f3a812d26', 'owner_id': '945577359662', 'private_dns_name': 'ip-172-31-40-50.ap-south-1.compute.internal', 'private_ip_address': '172.31.40.50', 'private_ip_addresses': [{'association': {'ip_owner_id': 'amazon', 'public_dns_name': 'ec2-35-154-112-147.ap-south-1.compute.amazonaws.com', 'public_ip': '35.154.112.147'}, 'primary': True, 'private_dns_name': 'ip-172-31-40-50.ap-south-1.compute.internal', 'private_ip_address': '172.31.40.50'}], 'source_dest_check': True, 'status': 'in-use', 'subnet_id': 'subnet-03d5cac27f2ede1f4', 'vpc_id': 'vpc-06e13c7cdf3e917f5', 'interface_type': 'interface'}], 'root_device_name': '/dev/xvda', 'root_device_type': 'ebs', 'security_groups': [{'group_name': 'Freedom', 'group_id': 'sg-09a5a43f8400c81c4'}], 'source_dest_check': True, 'tags': {'aws:ec2launchtemplate:version': '1', 'Name': 'Zomato-webserver', 'aws:ec2launchtemplate:id': 'lt-0acf1324f7d389679', 'aws:autoscaling:groupName': 'shopping-asg', 'Env': 'Dev', 'Project': 'Zomato'}, 'virtualization_type': 'hvm', 'cpu_options': {'core_count': 1, 'threads_per_core': 1}, 'capacity_reservation_specification': {'capacity_reservation_preference': 'open'}, 'hibernation_options': {'configured': False}, 'metadata_options': {'state': 'applied', 'http_tokens': 'required', 'http_put_response_hop_limit': 2, 'http_endpoint': 'enabled', 'http_protocol_ipv6': 'disabled', 'instance_metadata_tags': 'disabled'}, 'enclave_options': {'enabled': False}, 'boot_mode': 'uefi-preferred', 'platform_details': 'Linux/UNIX', 'usage_operation': 'RunInstances', 'usage_operation_update_time': '2023-07-01T11:11:36+00:00', 'private_dns_name_options': {'hostname_type': 'ip-name', 'enable_resource_name_dns_a_record': False, 'enable_resource_name_dns_aaaa_record': False}, 'maintenance_options': {'auto_recovery': 'default'}, 'current_instance_boot_mode': 'legacy-bios'})
  585. changed: [localhost] => (item={'ami_launch_index': 0, 'image_id': 'ami-0b9ecf71fe947bbdd', 'instance_id': 'i-0b4761ec172352872', 'instance_type': 't2.micro', 'key_name': 'mumbai-new', 'launch_time': '2023-07-01T11:11:36+00:00', 'monitoring': {'state': 'disabled'}, 'placement': {'availability_zone': 'ap-south-1b', 'group_name': '', 'tenancy': 'default'}, 'private_dns_name': 'ip-172-31-2-19.ap-south-1.compute.internal', 'private_ip_address': '172.31.2.19', 'product_codes': [], 'public_dns_name': 'ec2-65-0-87-36.ap-south-1.compute.amazonaws.com', 'public_ip_address': '65.0.87.36', 'state': {'code': 16, 'name': 'running'}, 'state_transition_reason': '', 'subnet_id': 'subnet-0c662917265d9d0e9', 'vpc_id': 'vpc-06e13c7cdf3e917f5', 'architecture': 'x86_64', 'block_device_mappings': [{'device_name': '/dev/xvda', 'ebs': {'attach_time': '2023-07-01T11:11:37+00:00', 'delete_on_termination': True, 'status': 'attached', 'volume_id': 'vol-0dd243cd99ffbc8ba'}}], 'client_token': '46862444-9ac2-9a4e-f074-06936da27bb3', 'ebs_optimized': False, 'ena_support': True, 'hypervisor': 'xen', 'network_interfaces': [{'association': {'ip_owner_id': 'amazon', 'public_dns_name': 'ec2-65-0-87-36.ap-south-1.compute.amazonaws.com', 'public_ip': '65.0.87.36'}, 'attachment': {'attach_time': '2023-07-01T11:11:36+00:00', 'attachment_id': 'eni-attach-013c3173b26695722', 'delete_on_termination': True, 'device_index': 0, 'status': 'attached', 'network_card_index': 0}, 'description': '', 'groups': [{'group_name': 'Freedom', 'group_id': 'sg-09a5a43f8400c81c4'}], 'ipv6_addresses': [], 'mac_address': '0a:ea:d0:e7:b0:54', 'network_interface_id': 'eni-059263a4b61df6a21', 'owner_id': '945577359662', 'private_dns_name': 'ip-172-31-2-19.ap-south-1.compute.internal', 'private_ip_address': '172.31.2.19', 'private_ip_addresses': [{'association': {'ip_owner_id': 'amazon', 'public_dns_name': 'ec2-65-0-87-36.ap-south-1.compute.amazonaws.com', 'public_ip': '65.0.87.36'}, 'primary': True, 'private_dns_name': 'ip-172-31-2-19.ap-south-1.compute.internal', 'private_ip_address': '172.31.2.19'}], 'source_dest_check': True, 'status': 'in-use', 'subnet_id': 'subnet-0c662917265d9d0e9', 'vpc_id': 'vpc-06e13c7cdf3e917f5', 'interface_type': 'interface'}], 'root_device_name': '/dev/xvda', 'root_device_type': 'ebs', 'security_groups': [{'group_name': 'Freedom', 'group_id': 'sg-09a5a43f8400c81c4'}], 'source_dest_check': True, 'tags': {'Env': 'Dev', 'aws:ec2launchtemplate:version': '1', 'aws:ec2launchtemplate:id': 'lt-0acf1324f7d389679', 'Project': 'Zomato', 'aws:autoscaling:groupName': 'shopping-asg', 'Name': 'Zomato-webserver'}, 'virtualization_type': 'hvm', 'cpu_options': {'core_count': 1, 'threads_per_core': 1}, 'capacity_reservation_specification': {'capacity_reservation_preference': 'open'}, 'hibernation_options': {'configured': False}, 'metadata_options': {'state': 'applied', 'http_tokens': 'required', 'http_put_response_hop_limit': 2, 'http_endpoint': 'enabled', 'http_protocol_ipv6': 'disabled', 'instance_metadata_tags': 'disabled'}, 'enclave_options': {'enabled': False}, 'boot_mode': 'uefi-preferred', 'platform_details': 'Linux/UNIX', 'usage_operation': 'RunInstances', 'usage_operation_update_time': '2023-07-01T11:11:36+00:00', 'private_dns_name_options': {'hostname_type': 'ip-name', 'enable_resource_name_dns_a_record': False, 'enable_resource_name_dns_aaaa_record': False}, 'maintenance_options': {'auto_recovery': 'default'}, 'current_instance_boot_mode': 'legacy-bios'})
  586.  
  587. PLAY [Rolling update] **************************************************************************************************
  588.  
  589. TASK [Gathering Facts] *************************************************************************************************
  590. ok: [172.31.45.142]
  591.  
  592. PLAY [Rolling update] **************************************************************************************************
  593.  
  594. TASK [Gathering Facts] *************************************************************************************************
  595. ok: [172.31.40.50]
  596.  
  597. PLAY [Rolling update] **************************************************************************************************
  598.  
  599. TASK [Gathering Facts] *************************************************************************************************
  600. ok: [172.31.2.19]
  601.  
  602. PLAY [Checking the package docker installed in remote_server] **********************************************************
  603.  
  604. TASK [Gathering Facts] *************************************************************************************************
  605. ok: [172.31.45.142]
  606. ok: [172.31.2.19]
  607. ok: [172.31.40.50]
  608.  
  609. TASK [Checking through package_facts] **********************************************************************************
  610. ok: [172.31.45.142]
  611. ok: [172.31.40.50]
  612. ok: [172.31.2.19]
  613.  
  614. TASK [Checking docker installed on remote servers] *********************************************************************
  615. fatal: [172.31.45.142]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'docker'. 'dict object' has no attribute 'docker'\n\nThe error appears to be in '/home/ec2-user/aws.yml': line 108, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n        - zomato\n    - name: \"Checking docker installed on remote servers\"\n      ^ here\n"}
  616. ...ignoring
  617. fatal: [172.31.40.50]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'docker'. 'dict object' has no attribute 'docker'\n\nThe error appears to be in '/home/ec2-user/aws.yml': line 108, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n        - zomato\n    - name: \"Checking docker installed on remote servers\"\n      ^ here\n"}
  618. ...ignoring
  619. fatal: [172.31.2.19]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'docker'. 'dict object' has no attribute 'docker'\n\nThe error appears to be in '/home/ec2-user/aws.yml': line 108, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n        - zomato\n    - name: \"Checking docker installed on remote servers\"\n      ^ here\n"}
  620. ...ignoring
  621.  
  622. TASK [Printing the 2nd register] ***************************************************************************************
  623. ok: [172.31.45.142] => {
  624.     "httpd_status": {
  625.         "failed": true,
  626.         "msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'docker'. 'dict object' has no attribute 'docker'\n\nThe error appears to be in '/home/ec2-user/aws.yml': line 108, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n        - zomato\n    - name: \"Checking docker installed on remote servers\"\n      ^ here\n"
  627.     }
  628. }
  629. ok: [172.31.40.50] => {
  630.     "httpd_status": {
  631.         "failed": true,
  632.         "msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'docker'. 'dict object' has no attribute 'docker'\n\nThe error appears to be in '/home/ec2-user/aws.yml': line 108, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n        - zomato\n    - name: \"Checking docker installed on remote servers\"\n      ^ here\n"
  633.     }
  634. }
  635. ok: [172.31.2.19] => {
  636.     "httpd_status": {
  637.         "failed": true,
  638.         "msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'docker'. 'dict object' has no attribute 'docker'\n\nThe error appears to be in '/home/ec2-user/aws.yml': line 108, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n        - zomato\n    - name: \"Checking docker installed on remote servers\"\n      ^ here\n"
  639.     }
  640. }
  641.  
  642. TASK [Install the package if not found in remote server] ***************************************************************
  643. changed: [172.31.40.50]
  644. changed: [172.31.45.142]
  645. changed: [172.31.2.19]
  646.  
  647. PLAY RECAP *************************************************************************************************************
  648. 172.31.2.19                : ok=6    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=1
  649. 172.31.40.50               : ok=6    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=1
  650. 172.31.45.142              : ok=6    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=1
  651. localhost                  : ok=3    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
  652.  
  653. [ec2-user@ip-172-31-6-232 ~]$ ssh -i aws.pem 172.31.45.142
  654.    ,     #_
  655.    ~\_  ####_        Amazon Linux 2023
  656.   ~~  \_#####\
  657.   ~~     \###|
  658.   ~~       \#/ ___   https://aws.amazon.com/linux/amazon-linux-2023
  659.    ~~       V~' '->
  660.    ~~~         /
  661.       ~~._.   _/
  662.          _/ _/
  663.        _/m/'
  664. Last login: Sat Jul  1 14:30:16 2023 from 172.31.6.232
  665. [ec2-user@ip-172-31-45-142 ~]$
  666. [ec2-user@ip-172-31-45-142 ~]$ docker version
  667. Client:
  668.  Version:          20.10.23
  669.  API version:      1.41
  670.  Go version:       go1.19.8
  671.  Git commit:       7155243
  672.  Built:            Mon May  1 21:07:11 2023
  673.  OS/Arch:          linux/amd64
  674.  Context:          default
  675.  Experimental:     true
  676. Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Advertisement
Add Comment
Please, Sign In to add comment