Posts

Showing posts from February, 2021

Work with Google OAuth2 Flow and Blogger API using PowerShell

Image
I haven't been very diligent on maintaining this blog. There has been quite a few SPAM comments accumulated on my posts. Turning on moderation is a good way to prevent them in the future. I still want to have an automated way to clean those SPAM comments. So over the weekend, I wrote this PowerShell script to achieve exactly this.  It will probably take way less time if I just manually go through the portal and delete those comments. But I learnt so much more about Google API and OAuth2 flow in the process of writing this small tool. Plus, now I have something to write about :) Google API can be access with both API key and OAuth2 token. However, the API key is only allowed for public accessible resources and actions like read a post or comment. Actions like deleting a post or comment require OAuth2 to be setup. Now let's look at how this is achieved for PowerShell. Setup the app in Google Developer Console Go to https://console.developers.google.com/ and setup a new project. U

Use Ansible to update Splunk Universal Forwarder Configuration

Today we will look at how to use Ansible to update Splunk UF (Universal Forwarder) configuration. The benefits of using Ansible to achive this are: - Save the hassel to manually modify conf files of syslog-ng and splunk uf. - Codify Splunk UF configuratoin, so they can be version controlled via GitHub. - Automate multiple UFs update without the need to ssh to each single server.  - The playbook can also be used to configure newly provisioned Spunk UF. Update log inputs on Splunk Universal Forwarder, normally invovles following tasks 1. Modify two configuratoin files: - Syslog-ng conf file in conf.d/syslog-ng.conf.  - Syslog app inputs config file under Splunk UF installation folder. 2. After the modification, Splunk service needs to be restarted. For configuration files, we use Jinja2 template to simpilify its format. The Jinja2 templates use parameters supplied from CSV file to populiate the final conf file. The Ansible playbook converts the template to conf file use template task. Th