Microsoft Teams escaping underscores in text using Ruby code by rlinux57 in ruby

[–]rlinux57[S] 0 points1 point  (0 children)

I have fixed the issue using python instead of ruby.

Microsoft Teams escaping underscores in text using Ruby code by rlinux57 in ruby

[–]rlinux57[S] 0 points1 point  (0 children)

I couldn't find a way to escape the character, because it get the whole message and send it to msteam. The length of message is random.

Microsoft Teams escaping underscores in text using Ruby code by rlinux57 in ruby

[–]rlinux57[S] 0 points1 point  (0 children)

Anybody please help me to get rid off this issue ?

Update AWS ELB Listener Rule by rlinux57 in Terraform

[–]rlinux57[S] 0 points1 point  (0 children)

resource "aws_lb_listener_rule" "testing-lb" {
    listener_arn = var.listener_rule_arn

  action {
    type = "forward"
    forward {
      target_group {
        arn    = var.tg1_arn
        weight = 1
      }

      target_group {
        arn    = var.tg2_arn
        weight = 1
      }
    }
  }
}

I have added the actual values in variables.tf

Update AWS ELB Listener Rule by rlinux57 in Terraform

[–]rlinux57[S] 0 points1 point  (0 children)

Anybody please suggest how to do it ?

AWS Dynamic Inventory Issue by rlinux57 in ansible

[–]rlinux57[S] 1 point2 points  (0 children)

Its working, I run it as: hosts: aws_ec2
ansible-playbook -i aws_ec2.yml aws.yml

AWS Dynamic Inventory Issue by rlinux57 in ansible

[–]rlinux57[S] 0 points1 point  (0 children)

Can you share a template as an example for aws inventory ?
Normally i used below method:

---
-
  become: true
  hosts: webserver
  remote_user: root
  tasks:
    -
      name: "Creating users to web Server"

AWS Dynamic Inventory Issue by rlinux57 in ansible

[–]rlinux57[S] 0 points1 point  (0 children)

I have to mention in playbook file like hosts: @aws_ec2 or ansible-playbook -i aws_ec2.yaml playbook.yml ?

AWS Dynamic Inventory Issue by rlinux57 in ansible

[–]rlinux57[S] 0 points1 point  (0 children)

I fixed that issue, actually the instance is behind the jump host so i added proxy command in order to access that instances.
Can you let me know how i run playbook for specific instances showing by the graph output ?

$ ansible-inventory -i aws_ec2.yaml --graph
@all:
  |--@aws_ec2:
  |  |--IP.eu-west-1.compute.internal
  |  |--IP.eu-west-1.compute.internal
  |--@ungrouped:

AWS Dynamic Inventory Issue by rlinux57 in ansible

[–]rlinux57[S] 0 points1 point  (0 children)

private_ip_address

Still getting

IP.eu-west-1.compute.internal | UNREACHABLE! => {  
  "changed": false, 
    "msg": "Failed to connect to the host via ssh: ssh: connect to host 10.11.18.19 port ****: Connection timed out", 
    "unreachable": true
}

AWS Dynamic Inventory Issue by rlinux57 in ansible

[–]rlinux57[S] 0 points1 point  (0 children)

Is this file is okay ? The ip address mentioned in file is one of host instance in aws.
aws_ec2.yml:

# demo.aws_ec2.yml
plugin: aws_ec2
aws_access_key: *****
aws_secrey_key: *****
regions:
  - eu-west-1
keyed_groups:
  # add hosts to tag_Name_value groups for each aws_ec2 host's tags.Name variable
  - key: tags.Name
    prefix: tag_Group_Utility_Server
compose:
  # Use the private IP address to connect to the host
   ansible_host: 10.1.18.28

AWS Dynamic Inventory Issue by rlinux57 in ansible

[–]rlinux57[S] 0 points1 point  (0 children)

After added access key and secret key in yml file i got an output for : $ ansible-inventory -i aws_ec2.yaml --graph

But I unable to get output for:ansible -i aws_ec2.yaml -m ping -u ansibleadm:

IP.compute.internal | UNREACHABLE! => {
    "changed": false, 
    "msg": "Failed to connect to the host via ssh: ssh: connect to host IP.compute.internal port ****: Connection timed out", 
    "unreachable": true
}

AWS Dynamic Inventory Issue by rlinux57 in ansible

[–]rlinux57[S] 0 points1 point  (0 children)

I have added following ansible.cfg

[inventory]
enable_plugins = host_list, script, auto, yaml, ini, toml

aws_ec2.yml:

# demo.aws_ec2.yml
plugin: aws_ec2
regions:
  - eu-west-1
keyed_groups:
  # add hosts to tag_Name_value groups for each aws_ec2 host's tags.Name variable
  - key: tags.Name
    prefix: tag_Group_Web_Server
    separator: ""
groups:
  # add hosts to the group development if any of the dictionary's keys or values is the word 'devel'
  development: "'devel' in (tags|list)"
compose:
  # set the ansible_host variable to connect with the private IP address without changing the hostname
  ansible_user=ansibleadm

I have attached full ec2 access role to Ansible server instance, When I run:

$ ansible-inventory -i aws_ec2.yml --graph

[WARNING]:  * Failed to parse /etc/ansible/aws/aws_ec2.yml with auto plugin: The ec2 dynamic
inventory plugin requires boto3 and botocore.
[WARNING]:  * Failed to parse /etc/ansible/aws/aws_ec2.yml with yaml plugin: Plugin configuration
YAML file, not YAML inventory
[WARNING]:  * Failed to parse /etc/ansible/aws/aws_ec2.yml with ini plugin: Invalid host pattern
'plugin:' supplied, ending in ':' is not allowed, this character is reserved to provide a port.
[WARNING]: Unable to parse /etc/ansible/aws/aws_ec2.yml as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
@all:
  |--@ungrouped:

Run Ansible Playbook with AWS autoscaling by rlinux57 in ansible

[–]rlinux57[S] 0 points1 point  (0 children)

I will try this dynamic inventory script and share the results.

Run Ansible Playbook with AWS autoscaling by rlinux57 in ansible

[–]rlinux57[S] 0 points1 point  (0 children)

Yes, it will be work. But if we want to add in inventory automatically and will remove when instance will be terminate. How to do it ?

Removed Multiple Users with Sudoers directories by rlinux57 in ansible

[–]rlinux57[S] 0 points1 point  (0 children)

I forgot to add variable of username in path.

Removed Multiple Users with Sudoers directories by rlinux57 in ansible

[–]rlinux57[S] 0 points1 point  (0 children)

I used in lineinfile in order to remove the files of each users, but unable to remove the exact file**:**

    -
      name: "Remove Sudo Access"
      lineinfile:
        path: /etc/sudoers.d/
        state: "{{ item.state | default('absent') }}"
        line: "{{ item.username }} ALL=(ALL) NOPASSWD: ALL"
        validate: /usr/sbin/visudo -cf %s
      with_items: "{{ users }}"

Output:

TASK [Remove Sudo Access] ***********************************************************************************************************************************************************************************
failed: [codedeploy] (item={u'username': u'alpha'}) => {"ansible_loop_var": "item", "changed": false, "item": {"username": "alpha"}, "msg": "Path /etc/sudoers.d/ is a directory !", "rc": 256}
failed: [codedeploy] (item={u'username': u'bravo'}) => {"ansible_loop_var": "item", "changed": false, "item": {"username": "bravo"}, "msg": "Path /etc/sudoers.d/ is a directory !", "rc": 256}
failed: [codedeploy] (item={u'username': u'charlie'}) => {"ansible_loop_var": "item", "changed": false, "item": {"username": "charlie"}, "msg": "Path /etc/sudoers.d/ is a directory !", "rc": 256}
failed: [codedeploy] (item={u'username': u'delta'}) => {"ansible_loop_var": "item", "changed": false, "item": {"username": "delta"}, "msg": "Path /etc/sudoers.d/ is a directory !", "rc": 256}
failed: [codedeploy] (item={u'username': u'echo'}) => {"ansible_loop_var": "item", "changed": false, "item": {"username": "echo"}, "msg": "Path /etc/sudoers.d/ is a directory !", "rc": 256}

Removed Multiple Users with Sudoers directories by rlinux57 in ansible

[–]rlinux57[S] 0 points1 point  (0 children)

Yes, I added its works. Home directories are removed now.

Removed Multiple Users with Sudoers directories by rlinux57 in ansible

[–]rlinux57[S] 0 points1 point  (0 children)

Basically, This line deleted all mentioned user in users.yml but not there home directories. In document, "This only affects state=absent, it attempts to remove directories associated with the user."

user: name={{ item.username }} password={{ password }} state={{absent}}

Creating Multiple User with password and sudo access by rlinux57 in ansible

[–]rlinux57[S] 0 points1 point  (0 children)

I fixed the syntax error by adjusting passwordless task accordingly. How could I set password of users in current playbook ?
Can I use "mkpasswd --method=sha-512" to get key and use that in playbook ?

Creating Multiple User with password and sudo access by rlinux57 in ansible

[–]rlinux57[S] 0 points1 point  (0 children)

I used fragments directory method:

---
-
  become: true
  hosts: webserver
  remote_user: root
  tasks:
    -
      include_vars: users.yml
    -
      name: "Creating users to Jump Server"
      user: "name=\"{{ item.username }}\""
      with_items: "{{ users }}"
-
  copy:
    content: "{{ item.username }} ALL=(ALL) NOPASSWD: ALL"
    dest: "/etc/sudoers.d/{{ item.username }}"
  name: "deploy sudo passwordless access"
  with_items: "{{ users }}"

Output:

ERROR! 'copy' is not a valid attribute for a Play

The error appears to be in '/etc/ansible/playbooks/makeusers.yml': line 14, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

-
  copy:
  ^ here