teleren/devto huggingface dataset:
Collect Failed Task Details in Ansible
Tags: ansible, prometheus, nodeexporter
Published: 2021-07-05 15:08:12

Recently, I've started working on Ansible to help our organization to roll out [Node Exporter](https://github.com/prometheus/node_exporter) in a wide scale. I've had few struggles during this journey and I believe each struggles teaches something. Hence I'll be starting few series about my struggles and what I learnt from that.

I know, first of all a big apologies to all of you, my dear readers. It's been quite a while I didn't blog. Lately, I've got busy with my day-to-day work and seriously didn't get much time (reason below). I'll try to blog as much as possible. Hope you all doing well during this pandemic. Let's jump on to the topic

Today, I would like to share a very useful tip which I struggled a lot to find it online. This is about collecting some useful information about failures in ansible, so that it will help you to perform some post validation after the execution across many servers.

For an example, in my case, we had to roll out [Node Exporter](https://github.com/prometheus/node_exporter) across 60k+ linux servers. And it was a nightmare if something failes and try to perform validation on why the failure was. Hence, we need some kind of reporting which can tell us some details about the server and the task which was failed with failure reason. I'm glad we nailed this as follows:

```yaml
tasks:
  - block:
      # Intentionally failing here
      - name: Deploy Node Exporter
        fail:
          msg: Failed intentionally
    rescue:
      - name: Record failure
        lineinfile:
          path: /tmp/execution-failures.csv
          line: '"{{ inventory_hostname }}","{{ tower_job_id }}","{{ ansible_failed_task[''name''] }}","{{ ansible_failed_result[''module_stderr''] }}","{{ ansible_failed_result[''stdout''] }}"'
          create: yes
        delegate_to: centralized.host.com
```

The trick here is `block...rescue` and in `rescue` capture some required key details for the validation. Here I'm capturing the following details:

- `inventory_hostname`: The destination host where the playbook is executed.
- `tower_job_id`: The ansible tower job id. Recording this in case if any ansible issues found, we'll report to ansible team with this detail for them to debug and help.
- `ansible_failed_task['name']`: Name of the failed task.
- `ansible_failed_result['module_stderr']`: Captures the stderr of the failed task. This is more important for us because this gives us details about the failure reason.
- `ansible_failed_result['stdout']`: This will be empty in most of the cases as the failed task will contain only `stderr`, not `stdout`. Keeping this for any unexpected.

Hope this helps. Shoot me with your questions here: https://github.com/email2vimalraj/site/issues/new

Originally published here: https://vimalselvam.com/post/ansible-collect-failed-tasks/
Day 132
Tags: 100daysofcode, programming
Published: 2021-07-05 15:18:23

Day 132/200 of #200DaysOfCode #100DaysOfCode 

- Solved two problems on Codewars.

1 -  Higher-Order Functions Series - Find the odd names (6 kyu)
2 -   Higher-Order Functions Series - Find the average age (7 kyu)
Data binding in Vuejs
Tags: vue, html, javascript, webdev
Published: 2021-07-05 15:12:36

In this article we are going explore a particularly interesting feature that has many applications. What is referred to as data-binding. Basically, through the framework, we can map the attributes of our html tags with values ​​provided by our Vue instance. We could bind for example the value of an input field:

```HTML
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<!-- importing vue js dev library -->
	<!-- development version, includes helpful console warnings -->
	<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
	<title>My vue Test</title>
</head>
<body>
	<div id="app">
		What's your name?
		<br>
		<input type="text" name="name" v-bind:value="name">
		<br>
		<button v-on:click="changeName()">
			change name
		</button>
	</div>
	<script type="text/javascript">
		var app = new Vue({ //instantiating the vue instance
		  el: '#app', //we select where vue is going to work in the DOM
		  data: {
		    name: 'Mattia'//this are the data
		  },
		  methods: {
		  	changeName: function() {
		  		this.name = "Martino";
		  	}
		  }
		})
	</script>
</body>
</html>
```

this is the resulting page:
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7i5ufkgb3y9x7c6t39dr.png)

If we click on the button, the name shown as value in the field will be changed immediately.
Box Comment plugin for VSCode
Tags: vscode, plugin, javascript, comment
Published: 2021-07-05 14:45:25

Spent some time on Saturday playing with the VSCode plugin system. The documentation is great and it's worth looking into if you're tempted to make your own plugins.

A while ago, I created [a quick prototype tool](https://prototypes.polymermallard.com/docblock/index.html) to format comments into clean ASCII boxes. I ended up using it a lot more than I thought I would, so I decided to turn it into [a plugin for VSCode](https://marketplace.visualstudio.com/items?itemName=polymermallard.box-comment).

---

#### Announcing
## Box Comment

![Demo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/53levjc72dw9pwtixupc.gif)

It generates a clean comment box using ascii box drawing characters around a selection.

```
# ┌──────────────────────────────────────────────────────┐
# │                                                      │
# │ This is a comment of documentation (Doc Block)       │
# │                                                      │
# │ @param Request $request                              │
# │ @return Response                                     │
# │ @throws \Exception                                   │
# │                                                      │
# └──────────────────────────────────────────────────────┘
```

### Configuration
The plugin defaults to single line box drawing and 80 characters wide. You can change these in your settings:

```
"box-comment.chars": {
        "tl": "╔",
        "tm": "═",
        "tr": "╗",
        "l" : "║",
        "r" : "║",
        "bl": "╚",
        "bm": "═",
        "br": "╝",
        "dl": "╠",
        "dm": "═",
        "dr": "╣"
    },
"box-comment.length": 80
``` 

### Usage

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x7mf9n2dzceu8qayidsv.png)

For Mac/PC: `shift+cmd+;` / `shift+alt+;` will run `Create comment box (via config)`


### Interested?

You can find it [here](https://marketplace.visualstudio.com/items?itemName=polymermallard.box-comment).
2077 theme for vscode
Tags: vscode, vscodetheme, showdev, 2077
Published: 2021-07-05 13:11:52

Hello there vscode users 👋!

If you're still looking for that theme that will catch your eye and you're looking for a futuristic looking theme while developing your applications, then this theme might be for you.

So, if the above matches you and you haven't tried the theme, you definitely should!

- [Marketplace](https://marketplace.visualstudio.com/items?itemName=Endormi.2077-theme)
- [Open VSX Registry](https://open-vsx.org/extension/Endormi/2077-theme)
- [GitHub](https://github.com/endormi/vscode-2077-theme) (Stars are very much appreciated!)

I started to develop this theme in March 2019, because I was anticipatingly waiting for Cyberpunk 2077 and wanted to develop my applications with a similar color palette. There weren't any themes in the marketplace with this particular color palette.

Certainly this theme is not for everyone and there might be certain things you want to change which is likely. 

Here is one tip (if you like the overall style of the theme, but don't like certain aspects):

You can add your customizations to your `settings.json` file.

```
"workbench.colorCustomizations": {
    "[2077]": {
        "editorIndentGuide.background": "#103483"
    }
}
```

If you like this futuristic style, but don't enjoy my theme.
Here are a few themes other people have created with the similar look:

- [SynthWave '84](https://marketplace.visualstudio.com/items?itemName=RobbOwen.synthwave-vscode)
- [Outrun](https://marketplace.visualstudio.com/items?itemName=samrapdev.outrun)
- [Tokyo Hack](https://marketplace.visualstudio.com/items?itemName=ajshortt.tokyo-hack)

> If you have a theme with the similar futuristic look, let me know in the comments and I will include it! :smile:.
AWS Data Lake with Terraform - Parts 6 of 6
Tags: awsdatalake, terraform, awsbigdata, aws
Published: 2021-07-05 14:42:56

##Amazon QuickSight

Amazon Quicksight is a business intelligence application similar to such tools like Tableau, Qlik and Microsoft Power BI that allows you to run interactive queries on large datasets also very SPICE (Super-fast, Parallel, In-memory, Calculation Engine).

You can create visualizations and dashboards in Amazon Quicksight for the data stored in your data lake. Visualizations are key to help individuals and business owners get a simpler and intuitive view of the current and historical states of your business evolution.

![Amazon QuickSight](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rvjhkj7odncuocng2ccc.png)

[picture above is from this link](https://aws.amazon.com/blogs/big-data/amazon-quicksight-now-supports-search-filter-groups-and-amazon-s3-analytics-connector/)


```
resource "aws_quicksight_user" "my_quicks" {
  user_name     = "an-author"
  email         = "author@example.com"
  identity_type = "IAM"
  user_role     = "AUTHOR"
}
```
**Conclusion**

This introductory series of articles are for teams/people who are about to explore data lakes. One fact that I want you to take with you after reading this is that creating a data lake is removing CPUs overload capacity and is allowing individuals and businesses to downscale their most expensive database cluster. This in turn, allows them to focus less on their infrastructure and more on the powerful insight that comes from their data analysis.
How to run or host WordPress with Caddy2 server
Tags: wordpress, caddy2, webdev, devops
Published: 2021-07-05 14:41:23

```
PHP Version       : 8.0
WordPress version : 5.7.2
Caddy version     : v2.4.3
```
---

## Installing Dependencies

To install WordPress, you must required to have PHP and MySQL or mariaDB

### Installing PHP

This is for Ubuntu/Debian Distro.

- `sudo apt update`
- `sudo apt install php php-cli php-fpm php-json php-common php-mysql php-zip php-gd php-mbstring php-curl php-xml php-pear php-bcmath`
- If the above command returns package not found or similar error do this step else go to next step, then you need to add the PPA, you can add them by `sudo add-apt-repository ppa:ondrej/php;sudo apt update` and now repeat the above step
- Now remove the apache2 server which is installed when installing PHP, by `sudo apt purge apache2*`
- Check the PHP Version by running `php -v`

### Installing MYSQL Database

If you don't have MYSQL installed refer this [blog by digitalocean](https://digitalocean.com/community/tutorials/how-to-install-mysql-on-ubuntu-20-04)

## Downloading Wordpress

- Navigate to the required directory, where do you want to save wordpress. here I use `/home/illuminate/php_sites`
- Download the latest Wordpress by `wget https://wordpress.org/latest.tar.gz`
- extract the tar file by `tar -xzvf latest.tar.gz`
- Delete the tar file after extraction completed
- go to the `wordpress/` by `cd wordpress`

## Creating DB for Wordpress

- If you have successfully installed mysql, create a seperate user and db for wordpress
- Login to mysql by `mysql -u adminusername -p` and now Enter the password
- replace the `databasename` with the database name you want.
```sql
CREATE DATABASE databasename;
use databasename;
CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
GRANT ALL ON *.* TO 'username'@'localhost';
flush privileges;
```
- After the above steps successful, exit the mysql by pressing `ctrl+d`

## Editing the Caddyfile

- Now add the entry to serve Wordpress

```caddy
example.com {
    root * /home/illuminate/php_sites/wordpress
    php_fastcgi unix//run/php/php8.0-fpm.sock
    file_server
    encode gzip

    @disallowed {
        path /xmlrpc.php
        path *.sql
        path /wp-content/uploads/*.php
    }

    rewrite @disallowed '/index.php'
}
```

- Now reload the caddy server.
- and its done.

## Configuring Wordpress

- When you visit the domain configured in caddyfile, it will ask to configure if not configured.
- Enter the database credentials as we created.
- If it fails to write `wp-config.php` file, then copy the configuration from web
- create a `wp-config.php` file inside the directory where `wp-content`, `wp-admin`, `wp-content` are present, for me its `/home/illuminate/php_sites/wordpress`
- paste the contents copied into the file, save and begin the installation.
How to Deploy Web App with Laravel Vapor?

Published: 2021-07-05 14:24:59

Hi All,

In this tutorial we will go over the demonstration of how to deploy project with laravel vapor. i would like to show you laravel vapor setup project. i explained simply about laravel vapor deploy web app. I’m going to show you about laravel serverless aws using vapor. you will do the following things for php laravel vapor aws setup.

Laravel introduce vapor for auto-scaling, serverless deployment platform for Laravel, powered by AWS Lambda. you can increase high traffic scalability using laravel vapor with AWS Lambda. Also Laravel Vapor provide domain management, Database Management, Environments Management, Queues, Storage, Networks, Cache, Logs etc.

Here, i will give you step by step information about how to setup your laravel project with vapor and aws lambda. so you must have AWS Account and Vapor Account you have. you just have to follow bellow steps and you can deploy your first app.

Link: https://www.itsolutionstuff.com/post/how-to-deploy-project-with-laravel-vaporexample.html
Get rating for you portfolio.
Tags: rate, portfolio, website, discuss
Published: 2021-07-05 14:22:40

I was thinking of taking a break from coding for one week so I thought of rating different developer's portfolio.


So what you need to do is simple just comment up your portfolio website's link and get a rating for your portfolio out of 10.


If you get less marks I will definetly give reason for that.


Thanks for reading my post please press the like and the unicorn button while going.
Thank you
Darsh kulthia
Windows Security Alert: Disable Print Spooler
Tags: security, privacy, systems
Published: 2021-07-05 13:59:50


Read about [PrintNightmare ](https://www.bleepingcomputer.com/news/security/public-windows-printnightmare-0-day-exploit-allows-domain-takeover/)

It's a quick fix!

Just disable Print Spooler service on Windows 10 and Windows Server environments.

- Open PowerShell as Administrator
- Run Command:

```powershell
Stop-Service -Name Spooler -Force
```

Prevent the service from starting back up again during restart:

```powershell
Set-Service -Name Spooler -StartupType Disabled
```

We hope this helps save you from ransomware.

 [Chapman Digital ](https://chapmandigital.co/)
What is QA outsourcing? Top Benefits of Software Testing outsourcing
Published: 2021-07-05 13:55:18

In this virtual world, there is one problem in font of all the companies and that is related to quality, time, infrastructure, and many more. 

Software testing outsourcing is the most common place in today’s IT world. In the era of digital world where companies always want their product with up to the market, companies always prefer to outsource their QA Testing to third party <a href="https://www.testrigtechnologies.com/">QA Companies <a/>and use the saved time and energy in software application development and delivery.

Software QA Testing Services is one of the top most activity where it will help the companies to make software stand out, or even help to survive in this competitive world.

 <b>What is the Meaning of Software Testing Outsourcing? </b>
Involve third party vendors or expert team of QA Experts in the process of QA Software Testing toward creating better products faster.

Here is the list of top advantages to outsourcing your QA software testing services.

1-Cost Effective
2-Better Quality
3-Improve Efficiency
4-Professional approach while implementing QA Activity
5-Reduce Infrastructure Cost

 <b>Cost Effective </b>

Outsourcing QA software testing can reduce your overall cost of development or testing. There are various other cost are involve in the QA Testing such as tools, resources, servers, databases, etc. by outsourcing QA Testing or hiring third party <a href="https://www.testrigtechnologies.com/service/web-automation-testing/">Web Test Automation Companies,<a/> we can cut down the costs related to this.
 
 <b>Better Quality  </b>

When we outsource QA or hire QA experts they can implement end to end software testing process with accurate quality which leads to better quality and better result.

 <b>Improve Efficiency </b>

By hiring third party offshore software testing services companies is beneficial as compare to hiring in-house QA Tester. You can focus on development and bug fixing software development process. This again leads to better product work efficiency and better 
security

 <b>Professional approach while implementing QA Activity </b>

To work with leading QA and software testing companies’ means QA process can be carried out by the leaders of QA world that is more accurate, professional and in structured flow. This will also lead to better test coverage and end with good QA Testing activity.

 <b>Reduce Infrastructure Cost </b>

According to experts, QA software testing needs good set of infrastructure to execute end to end QA Testing such as setup, stubs, and several tools for testing. By hiring third party QA agency you have to only choose the test automation tool so QA team can give the right directions. 

 <b>Conclusion  </b>
So, bottom of line is, you have to only choose the best QA testing service providers to execute proper QA Testing process
🔥🔥🔥 Develop Android Apps using React-native: Setup on Mac M1 and troubleshooting
Tags: m1, reactnative, android, install
Published: 2021-07-05 13:48:20

## Install Java and platform tools

Note that at the time of this writing, Java 16 is **NOT** supported by React Native! Java 8 is safe to install.

```shell
## Install Java and android platform tools
brew tap adoptopenjdk/openjdk
brew install --cask adoptopenjdk8
brew install android-platform-tools
```

##Install Android SDK
```bash
brew tap homebrew/cask
brew install --cask android-sdk
```

## Install Android Studio

Go to Google's Android Studio download page and install.

## Set environment variables

This is super important, and many errors in react-native CLI failed, because of these incorrect settings. Run below code in the terminal:

```shell
echo export "ANDROID_HOME=${HOME}/Library/Android/sdk" >> ~/.bash_profile
echo export "ANDROID_SDK_ROOT=${HOME}/Library/Android/sdk" >> ~/.bash_profile
echo export "ANDROID_AVD_HOME=${HOME}/.Android/avd" >> ~/.bash_profile

# Optional, for zsh shell only
echo "[[ -s ~/.bashrc ]] && source ~/.bashrc" >> ~/.bash_profile
```

To test if this is successful, try below:

```shell
source ~/.bash_profile
echo $ANDROID_HOME
```

## Install node.js/npm, yarn and Watchman
```shell
brew install node
brew install yarn
brew install watchman
```

Double check if every setting is good
```shell
npx react-native doctor
```

You will see some errors like below:
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/le2pwq5covr1v6dq76na.png)

You might wish to fix some of the errors, e.g. JDK with below commands:

```shell
brew install --cask adoptopenjdk11
```
Now the error will be fixed:
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jeiyhfdahcsuvfqmpzbp.png)
 
Note: You may ignore the Android SDK errors!
 

## Run command to create a new project

```shell
npx react-native init demo
```

## Install M1 Android Emulator

https://github.com/google/android-emulator-m1-preview or
https://github.com/741g/android-emulator-m1-preview/releases/tag/0.2

Download the DMG file and install the emulator as a Mac OSX app. Start the emulator before you run:
 
```shell
npx react-native run-android
```

Hooray! Now you should be able to run react native android app in Apple M1 desktops/laptops!

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hgnq4xeryrc2dkrss5kr.png)
Create a preconfigured instance on EC2 by AWS AMI - Hands On
Tags: aws, cloud, tutorial, beginners
Published: 2021-07-05 13:33:21

In the last article we studied what is an AMI and how it helps in creating preconfigured EC2 instances on AWS. In this exercise we will learn how to create a new AWS AMI with preconfigured Apache server on it.



* To create an AMI launch and EC2 instance like in the [second article of this series](https://dev.to/this-is-learning/start-an-instance-on-aws-ec2-hands-on-2hb3). Use the following script in userdata in place of script provided in the tutorial.

```bash
#!/bin/bash
# Use this for your user data (script from top to bottom)
# install httpd (Linux 2 version)
yum update -y
yum install -y httpd
systemctl start httpd
systemctl enable httpd

```
![Website image with Apache](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/namv9xoabec9qfnk0byy.png)

* Right click on the instance and select Images and Templates > Create Image
![Create Image with Ec2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/503l6ixgtjr3wxwcx5nv.png)

* Select an Image name and Description
![Select name desc](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fpyleng0xzssqlgmxw4t.png)

* Add a tag of you want to add a tag, let rest of the settings remain same. Click create image to create an image
![add tag](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/96xnvi0fgh3j7sovw350.png)

* This we will create a snapshot of the root EBS volume and create a image from it


* Now wait for a few minutes after that check the AMI tab under Images to see if the AMI is created
![Ami pending](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hbrml0rvqp1mcwgg9h7v.png)
![Ami Pending](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rch16jxdisrag85dydgt.png)

* One this is done follow [second article of this series](https://dev.to/this-is-learning/start-an-instance-on-aws-ec2-hands-on-2hb3) to create the instance again but in the second step instead of selecting Amazon AMI select My AMI there you will see your AMI select that and in the userdata add this script instead of the one there

```bash
#!/bin/bash
echo "<h1>Hello World from $(hostname -f)</h1>" > /var/www/html/index.html
```
beacuse we already installed apache server in our AMI
![Created AMI](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lc1gssedcvqbvg3y8ud0.png)

* Once you are done with the select the public IP address you will see the same page running in the server.


![Ec2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p0houyi9cpt95wgeaizk.png)
![Website](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s8knqj2aymicl2gkmiav.png)

## Cleanup

Clean all these Ec2 instances they may cost you money

In the next article we will see how to automate creation of these AMI's
Created my first NPM package with typescript.
Tags: npm, typescript
Published: 2021-07-05 13:31:48


I created my first npm package with the help of typescript.

[npm link](https://www.npmjs.com/package/moviestmdb)
[github link](https://github.com/sarthak090/moviestmdb)

## Moviestmdb
this package help to interact with tmdb api easily. The package is built with typescript so all the response types are pre-defined .