Re: [ansible-project] What is the right tool to make yml files on Windows 10?

2020-09-23 Thread Karl Auer
Any text editor will work, but don't use a word-processor. You need to
generate plain ascii files.

If you can afford the slight learning curve, see if you can find a
programming editor you like. Visual Studio Code is free, multi-platform and
excellent, but there are plenty of others that will understand YAML, do
syntax highlighting and help you get the indentation right and avoid silly
syntactical mistakes.

Me - I use vi :-)

Regards, K.


On Wed, Sep 23, 2020 at 6:00 PM Prabhakaran Karuppaih <
arrow.prabhaka...@gmail.com> wrote:

> You know... There must be some Software tool like Notepad, Wordpad or
> Microsoft Word..
> How about Atos?
> Or Notepad++ Maybe..
>
> My core learning is not with ansible. I just want to run some
> Playbooks...(On CentOS 7) to install Asterisk on the same and Mastering the
> Asterisk tool...
>
> With Hope,
> Prabhakaran
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/6637e0ac-ff73-4e0c-b4ec-96e3d31afe15n%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/6637e0ac-ff73-4e0c-b4ec-96e3d31afe15n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 

*Karl Auer* { manager, systems support }
P: 1300 759 975
E: ka...@2pisoftware.com
2pisoftware.com

GPG/PGP : DF6A 43E5 FB9D D884 C6CA CD7F 5278 212D E80F C107
Previous: 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08SuMj4hjNYxMT6J3teGuPZMphUjjm%3DiKV9%3DGihyf5%3DdgQ%40mail.gmail.com.


Re: [ansible-project] correct csv format

2020-08-24 Thread Karl Auer
Hullo Monica

I'm not sure, but I seem to remember there is a CSV filter of some sort in
Ansible, you could try looking for that.

Without knowing the format of the input you are using, it's hard to advise,
but one option might be to output the columns into three separate files
(without commas), and using the paste utility to paste them together.

Can you provide some sample input? Also, what does PFB mean?

Regards, K.
On Mon, Aug 24, 2020 at 6:11 PM Monica D  wrote:

> Hi All,
>
> I am facing issue while storing the output to a csv file using a shell
> module.
> PFB my script written-:
>   - name: list output to CSV
> shell: echo "{{ item  }}" >> file_output.csv
> delegate_to: 127.0.0.1
> with_items: "{{ output }}"
>
> *the output of csv file-:*
>
> server1
> server2
> server3
> PermitEmptyPasswords no
> PermitEmptyPasswords no
> PermitEmptyPasswords no
> Found
> Not Found
> Not Found
>
> *But I want output in this format-:*
>
> server1, PermitEmptyPasswords no , Found
> server2, PermitEmptyPasswords no , Not Found
> server3, PermitEmptyPasswords no , Not  Found
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/311645d5-6642-4445-b434-9a9a0e6689bbn%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/311645d5-6642-4445-b434-9a9a0e6689bbn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 

*Karl Auer* { manager, systems support }
P: 1300 759 975
E: ka...@2pisoftware.com
2pisoftware.com

GPG/PGP : DF6A 43E5 FB9D D884 C6CA CD7F 5278 212D E80F C107
Previous: 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08SaPzF8-1yY3mQijVqA0cCugWzoLtC6j%3DLWMC--LcwtsA%40mail.gmail.com.


Re: [ansible-project] GIT configuration using ansible

2020-08-23 Thread Karl Auer
Are the global values not set, or are they set but not used? Wondering if
--system would be more appropriate than --global. If you use --global, then
it will set the values for whatever user Ansible is connecting as. This may
or may not be the right user for later git usage.

--local is per- repository, --global is per-user (but may be overridden by
--local), and --system is for everyone (but may be overridden by --global
or --local).

You should be able to find out what is being set by inspecting the local,
global and system locations after Ansible runs. I don't know what they are
in Windows, but for Linux they would be <*repodir*>/.git/config,
~/.gitconfig, and /etc/gitconfig respectively.

Regards, K.


On Mon, Aug 24, 2020 at 3:55 PM surabhy vaishakh 
wrote:

> Hello Team,
>
> I want to install git using  ansible and try to configure using below
> commands.
>
> git config --global user.name "Your Name" (Choose a proper name. Eg:
> surabhy.mr)
> git config --global user.email "surabh...@gmail.com"
>
> I am able to install GIT but unable to configure.
>
> ---
> - hosts: win
>   gather_facts: true
>   tasks:
> # Make etckeeper not complain when invoked by cron
>   - git_config:
>   name: user.name
>   scope: global
>   value: 'surabhy.mr'
>   - git_config:
>   name: user.email
>   scope: global
>   value: 'surabh...@gmail.com
>
> Pls help asap'
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/c084db28-cdad-46cd-b913-a9e07c16a9dcn%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/c084db28-cdad-46cd-b913-a9e07c16a9dcn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 

*Karl Auer* { manager, systems support }
P: 1300 759 975
E: ka...@2pisoftware.com
2pisoftware.com

GPG/PGP : DF6A 43E5 FB9D D884 C6CA CD7F 5278 212D E80F C107
Previous: 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08RsBLZ3foob%3DEHGUHEoO%3DNOSZtGxdkuo8JbZZs8fCGY%3Dg%40mail.gmail.com.


Re: [ansible-project] AWS EFS

2020-08-11 Thread Karl Auer
mod_name='ansible.modules.cloud.amazon.efs',
> init_globals=None, run_name='__main__', alter_sys=True)\n  File
> \"/usr/lib/python2.7/runpy.py\", line 188, in run_module\nfname,
> loader, pkg_name)\n  File \"/usr/lib/python2.7/runpy.py\", line 82, in
> _run_module_code\nmod_name, mod_fname, mod_loader, pkg_name)\n  File
> \"/usr/lib/python2.7/runpy.py\", line 72, in _run_code\nexec code in
> run_globals\n  File
> \"/tmp/ansible_efs_payload_0gaJT5/ansible_efs_payload.zip/ansible/modules/cloud/amazon/efs.py\",
> line 765, in \n  File
> \"/tmp/ansible_efs_payload_0gaJT5/ansible_efs_payload.zip/ansible/modules/cloud/amazon/efs.py\",
> line 746, in main\n  File
> \"/tmp/ansible_efs_payload_0gaJT5/ansible_efs_payload.zip/ansible/modules/cloud/amazon/efs.py\",
> line 400, in create_file_system\n  File
> \"/tmp/ansible_efs_payload_0gaJT5/ansible_efs_payload.zip/ansible/modules/cloud/amazon/efs.py\",
> line 345, in get_file_system_state\n  File
> \"/tmp/ansible_efs_payload_0gaJT5/ansible_efs_payload.zip/ansible/modules/cloud/amazon/efs.py\",
> line 672, in first_or_default\n  File
> \"/tmp/ansible_efs_payload_0gaJT5/ansible_efs_payload.zip/ansible/modules/cloud/amazon/efs.py\",
> line 629, in iterate_all\n  File
> \"/usr/lib/python2.7/dist-packages/botocore/client.py\", line 316, in
> _api_call\nreturn self._make_api_call(operation_name, kwargs)\n  File
> \"/usr/lib/python2.7/dist-packages/botocore/client.py\", line 622, in
> _make_api_call\noperation_model, request_dict, request_context)\n  File
> \"/usr/lib/python2.7/dist-packages/botocore/client.py\", line 641, in
> _make_request\nreturn self._endpoint.make_request(operation_model,
> request_dict)\n  File
> \"/usr/lib/python2.7/dist-packages/botocore/endpoint.py\", line 102, in
> make_request\nreturn self._send_request(request_dict,
> operation_model)\n  File
> \"/usr/lib/python2.7/dist-packages/botocore/endpoint.py\", line 132, in
> _send_request\nrequest = self.create_request(request_dict,
> operation_model)\n  File
> \"/usr/lib/python2.7/dist-packages/botocore/endpoint.py\", line 116, in
> create_request\noperation_name=operation_model.name)\n  File
> \"/usr/lib/python2.7/dist-packages/botocore/hooks.py\", line 356, in
> emit\nreturn self._emitter.emit(aliased_event_name, **kwargs)\n  File
> \"/usr/lib/python2.7/dist-packages/botocore/hooks.py\", line 228, in
> emit\nreturn self._emit(event_name, kwargs)\n  File
> \"/usr/lib/python2.7/dist-packages/botocore/hooks.py\", line 211, in
> _emit\nresponse = handler(**kwargs)\n  File
> \"/usr/lib/python2.7/dist-packages/botocore/signers.py\", line 90, in
> handler\nreturn self.sign(operation_name, request)\n  File
> \"/usr/lib/python2.7/dist-packages/botocore/signers.py\", line 160, in
> sign\nauth.add_auth(request)\n  File
> \"/usr/lib/python2.7/dist-packages/botocore/auth.py\", line 357, in
> add_auth\nraise
> NoCredentialsError\nbotocore.exceptions.NoCredentialsError: Unable to
> locate credentials\n",
> "module_stdout": "",
> "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
> "rc": 1
> }
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/91211d18-88d5-476b-afc9-a61fe96b5793n%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/91211d18-88d5-476b-afc9-a61fe96b5793n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 

*Karl Auer* { manager, systems support }
P: 1300 759 975
E: ka...@2pisoftware.com
2pisoftware.com

GPG/PGP : DF6A 43E5 FB9D D884 C6CA CD7F 5278 212D E80F C107
Previous: 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08QRCH5t7Rj%2B0_A%3DtNVjrLATr1J%3DLFd17ymYS-isBoAmBQ%40mail.gmail.com.


Re: [ansible-project] Need Guidance

2020-07-28 Thread Karl Auer
There needs to be a variable called "openjdk_yumlock_version7" containing
the actual value that needs to follow the word "delete" in that command.

You are seeing that error because there is no such variable.

Regards, K.

On Wed, Jul 29, 2020 at 1:45 AM Amar Subudhi  wrote:

> Hi Experts,
>
> I am getting the below error while executing the playbook.
> Thanks in Advance.
>
> Playbook-
>
> - name: RedHat unlock OpenJdk version
>   command: yum versionlock delete '{{openjdk_yumlock_version7}}'
>   when: ansible_distribution_major_version == "7"
>   ignore_errors: yes
>
> Error
> TASK [openjdk : RedHat unlock OpenJdk version]
> **
> Tuesday 28 July 2020  10:54:25 -0400 (0:00:00.106)   0:00:03.705
> **
> fatal: [hsdsqa09]: FAILED! => {"msg": "The task includes an option with an
> undefined variable. The error was: 'openjdk_yumlock_version7' is
> undefined\n\nThe error appears to have been in
> '/opt/hd/sh/srv/ansible/development/axs8u3p/hadoop/roles/openjdk/tasks/main.yml':
> line 9, column 3, but may\nbe elsewhere in the file depending on the exact
> syntax problem.\n\nThe offending line appears to be:\n\n\n- name: RedHat
> unlock OpenJdk version\n  ^ here\n"}
> ...ignoring
>
>
> Playbook
> - name: install openjdk from rhel-x86_64-server-7-datacenter
>   package:
>  name: "{{openjdk_package_name7}}"
>  state: present
>   when: ansible_distribution_major_version == "7"
>
> Error
> TASK [openjdk : install openjdk from rhel-x86_64-server-7-datacenter]
> ***
> Tuesday 28 July 2020  10:54:26 -0400 (0:00:00.105)   0:00:03.916
> **
> fatal: [hsdsqa09]: FAILED! => {"msg": "The task includes an option with an
> undefined variable. The error was: 'openjdk_package_name7' is
> undefined\n\nThe error appears to have been in
> '/opt/hd/sh/srv/ansible/development/axs8u3p/hadoop/roles/openjdk/tasks/main.yml':
> line 20, column 3, but may\nbe elsewhere in the file depending on the exact
> syntax problem.\n\nThe offending line appears to be:\n\n\n- name: install
> openjdk from rhel-x86_64-server-7-datacenter\n  ^ here\n"}
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/8f2cd7f4-dcfd-4eb1-b92f-8d29825332dao%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/8f2cd7f4-dcfd-4eb1-b92f-8d29825332dao%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 

*Karl Auer* { manager, systems support }
P: 1300 759 975
E: ka...@2pisoftware.com
2pisoftware.com

GPG/PGP : DF6A 43E5 FB9D D884 C6CA CD7F 5278 212D E80F C107
Previous: 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08THHHau_954QKvnW6YPNTEz1gVX7MAetKy-iHKj76Z0BA%40mail.gmail.com.


Re: [ansible-project] How to split value from list

2020-07-06 Thread Karl Auer
so what's wrong with:

USR="jenisha"
FOUND=`grep $USR /etc/passwd | cut -d: -f1`
if [ -z "$FOUND" ] ; then
   echo "No such user: $USR"
else
   # do whatever...
fi

?

Regards, K.


On Tue, Jul 7, 2020 at 3:11 PM T. JENISHA  wrote:

> In my case cut doesn't work. I m searching for a particular user from a
> password.
> $ grep anil /etc/passwd
>
>
> Best Regards
> Jenisha T
> Whatsapp: +91 07598087866
>
>
>
>
>
> On Mon, 6 Jul 2020 at 19:50, Stefan Hornburg (Racke) 
> wrote:
>
>> On 7/6/20 3:32 PM, Srinivas Naram wrote:
>> > Hello Jenisha,
>> >
>> > Assuming that you are getting this value from /etc/passwd., try to
>> change you command
>> >
>> >  tail -1 /etc/passwd | awk '{split($0,a,":"); print a[1]}'
>> >
>>
>> cut -d : -f 1 is more concise and readable than your awk command.
>>
>> Otherwise I would really like to know why Jenisha resorts to reading the
>> password file.
>>
>> Regards
>>  racke
>>
>>
>> > On Mon, Jul 6, 2020 at 6:35 PM Dick Visser > <mailto:dick.vis...@geant.org>> wrote:
>> >
>> > you should either use set_fact, or register. Both doesn't make
>> sense.
>> >
>> > On Mon, 6 Jul 2020 at 13:44, Jenisha T > joyj...@gmail.com>> wrote:
>> > >
>> > > Hi
>> > > Could you pls help me with the splitting value from the list. I
>> need to extract first value anil before ('':')
>> > >
>> > >  grep_atm.stdout_lines output below
>> > >
>> > > ok: [localhost] => {
>> > > "msg": "anil:x:500:500:Anil:/home/anil:/bin/bash
>> > > "
>> > > }
>> > >
>> > > I tried,
>> > > - set_fact:
>> > >user_name: "{{ grep_atm.stdout_lines }}"
>> > > register: user_name.split(':')[0]
>> > >  - debug:
>> > > var: user_name.split(':')[0]
>> > >
>> > > --
>> > > You received this message because you are subscribed to the
>> Google Groups "Ansible Project" group.
>> > > To unsubscribe from this group and stop receiving emails from it,
>> send an email to
>> > ansible-project+unsubscr...@googlegroups.com > ansible-project%2bunsubscr...@googlegroups.com>.
>> > > To view this discussion on the web visit
>> >
>> https://groups.google.com/d/msgid/ansible-project/42fb2917-8336-42a2-979a-44573e91fd77n%40googlegroups.com
>> .
>> >
>> >
>> >
>> > --
>> > Dick Visser
>> > Trust & Identity Service Operations Manager
>> > GÉANT
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> Groups "Ansible Project" group.
>> > To unsubscribe from this group and stop receiving emails from it,
>> send an email to
>> > ansible-project+unsubscr...@googlegroups.com > ansible-project%2bunsubscr...@googlegroups.com>.
>> > To view this discussion on the web visit
>> >
>> https://groups.google.com/d/msgid/ansible-project/CAL8fbwMo1%3D9XhddQY_BDaREzKLRGS_xDvZbtu1o5UCj0R1h%3Duw%40mail.gmail.com
>> .
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> Groups "Ansible Project" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> an email to
>> > ansible-project+unsubscr...@googlegroups.com > ansible-project+unsubscr...@googlegroups.com>.
>> > To view this discussion on the web visit
>> >
>> https://groups.google.com/d/msgid/ansible-project/CAG-N3P7NNjnbv7fZ5Vx0vmmTTyd9KntKpY-yOm75csqJ50cBmA%40mail.gmail.com
>> > <
>> https://groups.google.com/d/msgid/ansible-project/CAG-N3P7NNjnbv7fZ5Vx0vmmTTyd9KntKpY-yOm75csqJ50cBmA%40mail.gmail.com?utm_medium=email&utm_source=footer
>> >.
>>
>>
>> --
>> Ecommerce and Linux consulting + Perl and web application programming.
>> Debian and Sympa administration. Provisioning with Ansible.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Ansible Project" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to ansible-pro

Re: [ansible-project] ec2 instance not reachable

2020-06-06 Thread Karl Auer
A security group has no effect until it is attached to an interface.

You will need to attach your new security group to the interface on the EC2
instance before you will be able to reach the instance on port 22.

Regards, K.

On Sun, Jun 7, 2020 at 2:14 PM Sanjay Chakraborty 
wrote:

> Hi guys,
> I need to set up some ec2 instances for my project and I am in the process
> of doing proof of concept.
>
> My playbook creates an aws ec2 instance and  I am using an already created
> security group that includes ssh however for some reason it is failing to
> open the port 22.
>   launch_east_cost_ec2.yml:
>
> - name: Launch new EC2 instance
>hosts: localhost
>connection: local
>gather_facts: false
>vars:
>  pem: keyname
>  reg: us-east-1
>
>tasks:
>  - name: create ec2 instance with default values
>ec2:
>  instance_type: t2.micro
>  image: ami-xxx
>  region: "{{ reg }}"
>  keypair: "{{ pem }}"
>  aws_access_key: xx
>  aws_secret_key: xxx
>  - name: add ssh to ec2
>ec2_group:
>  name: setup_ssh_connection
>  description: a setup ssh connection for ec2
>  vpc_id: vpc-
>  region: "{{ reg }}"
>  rules:
>   - proto: tcp
> ports:
> - 22
> cidr_ip: 0.0.0.0/0
> group_id: x
>  - name: wait for rsystem to become reachable
>wait_for_connection:
>  timeout: 3600 --> i changed to few different values but no luck.
> Output:
>
>
>
>
> TASK [add ssh to ec2]
> 
> [WARNING]: Ran out of time waiting for sg-x IpPermissions. Current:
> set([Rule(port_range=(22, 22), protocol=u'tcp', target=('2345423355',
> 'sg-xx', None),
> target_type='group', description=None), Rule(port_range=(22, 22),
> protocol=u'tcp', target='0.0.0.0/0', target_type='ipv4',
> description=None)]), Desired: [Rule(port_range=(22, 22),
> protocol=u'tcp', target='sg-xx', target_type='group',
> description=None), Rule(port_range=(22, 22), protocol=u'tcp', target='
> 0.0.0.0/0', target_type='ipv4', description=None)]
> changed: [localhost]
>
> TASK [wait fo rsystem to become reachable]
> ***
> [WARNING]: Reset is not implemented for this connection
> ok: [localhost]
>
> PLAY RECAP
> ***
> localhost  : ok=3changed=2unreachable=0
>  failed=0skipped=0rescued=0ignored=0
>
>
>
> Please advise what is missing.
>
> Thank you in advance.
> Sanjay
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAHOFgkS3bTJZo3KpfGu6EUBaRXaVg70LOJegZiHdR27DBtTOXw%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CAHOFgkS3bTJZo3KpfGu6EUBaRXaVg70LOJegZiHdR27DBtTOXw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>


-- 

*Karl Auer* { manager, systems support }
P: 1300 759 975
E: ka...@2pisoftware.com
2pisoftware.com

GPG/PGP : DF6A 43E5 FB9D D884 C6CA CD7F 5278 212D E80F C107
Previous: 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08R_kRFS%3DTF%2BCt%3DCgZBaO%2BvqyOsL1bNJf1SU8JqcT0t0tA%40mail.gmail.com.


Re: [ansible-project] How to schedule a task which should be run after every 30 mins

2020-04-21 Thread Karl Auer
Create a script (e.g. in bash) that does everything you want to do,
including run Ansible.

Then create a cron-job which runs that script at the intervals you desire.

Regards, K.

On Tue, Apr 21, 2020 at 3:32 PM Samir Kothawade 
wrote:

> Hi,
>
> I want to execute specified task in ansible playbook after every 30 mins.
> Task is not just a command, so "at" module does not work in my case or may
> be I am not doing it in proper way :
>
> Here is my play book. Playbook below runs correctly for single time. I
> want to collect the stats after every 30 mins, so how should I do that...
> Can you guys please suggest solution ?
>
> - hosts: zmr
>   gather_facts: no
>   vars:
>  date: "{{ lookup('pipe', 'date +%Y%m%d-%H%M') }}"
>   tasks:
>   - name: set the winsize
> shell: stty cols 5000 rows 5000
>   - name: Get the debug status
> ignore_errors: yes
> expect:
>   command: /opt/wishu/ZMR_Platform/bin/go_zmr_cli
>   timeout: 5
>   responses:
> (.*)Username:(.*): "admin"
> (.*)Password:(.*): "admin"
> (.*)ZMR>(.*): display debug info PP ip 192.168.30.26 port 8686
> (.*):(.*): " q"
>   timeout: 30
> register: stats
>   - local_action: copy content="{{ stats_.stdout}}"
> dest="/home/sam/stats_{{ lookup('pipe', 'date +%Y%m%d-%H%M') }}.txt"
> ignore_errors: yes
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/43514f7d-40fb-4262-b7de-1a7921edbc0a%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/43514f7d-40fb-4262-b7de-1a7921edbc0a%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 

*Karl Auer* { manager, systems support }
P: 1300 759 975
E: ka...@2pisoftware.com
2pisoftware.com

GPG/PGP : DF6A 43E5 FB9D D884 C6CA CD7F 5278 212D E80F C107
Previous: 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08TZztrePCB2pj5kBQq%3Dfb8O0fj7LmpLKmn2Y8Qn9g2gFw%40mail.gmail.com.


Re: [ansible-project] Re: Relation between Ansible and SDN

2020-04-20 Thread Karl Auer
Hullo Nabil.

On Mon, 20 Apr 2020 at 13:44, nabil hama  wrote:>
> I have confusion between the utilization of Ansible and  SDN,   As long as
> the

SDN offers network automation, optimization and high flexibility, what is
> the

role of Ansible in that network?  are two different subjects and work
> totally

separately?
>

They are two different subjects and work totally separately. However, if
you can find (or write!) Ansible modules that manipulate SDNs, you could
then use Ansible to do that.

Regards, K.



-- 

*Karl Auer* { manager, systems support }
P: 1300 759 975
E: ka...@2pisoftware.com
2pisoftware.com

GPG/PGP : DF6A 43E5 FB9D D884 C6CA CD7F 5278 212D E80F C107
Previous: 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08QiQWrSZ67CRtCBVfKvQxroAXGAY2SmZzq9v667cUH4gA%40mail.gmail.com.


Re: [ansible-project] Relation between Ansible and SDN

2020-04-20 Thread Karl Auer
There is no relationship between Ansible and SDN.

Ansible is a general tool. There may be Ansible modules that allow you to
manipulate particular SDNs.

I suggest you start by googling "Ansible SDN" and see where the journey
takes you.

Regards, K.


On Mon, Apr 20, 2020 at 8:25 PM nabil hama  wrote:

> Hello,
>
> Please, could explain to me, that is the relation between Ansible and SDN,
> how it can work together? with what architecture?
>
> thanks in advance
>
> BR
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/832c2de3-2a05-4e01-9d16-1bcb6201f5a9%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/832c2de3-2a05-4e01-9d16-1bcb6201f5a9%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 

*Karl Auer* { manager, systems support }
P: 1300 759 975
E: ka...@2pisoftware.com
2pisoftware.com

GPG/PGP : DF6A 43E5 FB9D D884 C6CA CD7F 5278 212D E80F C107
Previous: 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08SYWKGeYZ_G5oGQAKFdT-89p2wqz1DBi6jwwkZgQAR%2BfA%40mail.gmail.com.


Re: [ansible-project] Re: How to change remote hosts' terminal screen size/resolution in Ansible

2020-04-19 Thread Karl Auer
I've offered all the help I can. Your best bet is to contact the people who
wrote the program you are trying to use.

You may find it easier to do things like set environment variables and
redirect output using the shell module:

https://docs.ansible.com/ansible/latest/modules/shell_module.html#shell-module

Also, it would be a VERY good idea to test things out manually before
trying to do them in Ansible.

Good luck, K.


On Sun, Apr 19, 2020 at 4:26 PM Samir Kothawade 
wrote:

>
>
> On Sun, 19 Apr 2020 at 05:24, Karl Auer  wrote:
>
>> TERM=dumb
>>
>> Sorry, I mistyped. The minus sign should have been an equals sign.
>>
>> >> >> Can you please help me where I can use this in my code and see the
> content in a text file ? Here is  my anible code...pasting it here again
>  *-** hosts: sam*
> *  gather_facts: no*
> *  tasks:*
> *  - name: capture all stats*
> *ignore_errors: yes*
> *expect:*
> *  command: /opt/abc/xyz_Platform/bin/go_xyz_cli*
> *  responses:*
> *(.*)Username:(.*): "admin"*
> *(.*)Password:(.*): "admin"*
> *(.*)xyz_cli>(.*): display all debug stats*
> *(.*):(.*): ''*
> *register: stats*
> *  - local_action: copy content="{{ stats.stdout}}"
> dest="/home/sam/quickstats/stats.txt"*
> *ignore_errors: yes*
>
>> The idea is to set the environment variable TERM to the value "dumb"
>> immediately before starting the shell in which your program will be run.
>>
>> Also can you please answer the question about whether you can redirect
>> the output of this program?
>>
>
> >> NO. There no support on that binary to copy or to point the output to
> some file. Shell commads like " >>abc.txt " does not work.
>
>>
>> I strongly suggest you experiment manually rather than with Ansible. You
>> need to find out how to achieve what you want, then duplicate that in
>> Ansible. Doing both at once is very painful.
>>
>>
> >>  Yes. I have done this manually.
> *For collecting stats manually here is the procedure :*
> 1. I use mouse > Select the area of stats appeared on screen (after
> selecting area, termius utility copy the selected area automatically) >
> 2. Paste it manually by pressing ctr+v into sublime text editor
> 3. Again go to remote machine and press down key/Enter key to collect
> remaining stats and copy-paste the status in similarly way as mentioed in
> step 1 and 2.
> 4. I have to perform step 1,2,3 multiple times untill I copy all the
> status, as window can display only 25-30 lines/rows. Some times for doing
> it quickly, I use zoom-out (Ctr++), by this I can copy more lines.
> But I want to do this operation through automation.
>
>> Regards, K.
>>
>> On Sun, Apr 19, 2020 at 2:34 AM Samir Kothawade <
>> kothawade.sa...@gmail.com> wrote:
>>
>>> bash: TERM-dumb: command not found.
>>>
>>> gnome-terminal utility not available on remote  machine
>>>
>>>
>>> On Sat, 18 Apr 2020 at 21:53, Karl Auer  wrote:
>>>
>>>> You *might* be able to convince the console on the remote system to be
>>>> a dumb terminal by doing this as your command:
>>>>
>>>> TERM-dumb ; sh -c your_command
>>>>
>>>> This works in gnome-terminal as well - it seems to suppress most
>>>> control sequences except CR/LF and similar.
>>>>
>>>> Or in Ansible, setting the environment variable TERM to "dumb" then
>>>> running your command in a new shell. In my experiments here, when I set
>>>> TERM=dumb and ran sh from within a console or from within
>>>> gnome-terminal, the colourisation went away. However the console still
>>>> had a fixed number of lines.
>>>>
>>>> Regards, K.
>>>>
>>>> On Sun, Apr 19, 2020 at 1:04 AM Samir Kothawade <
>>>> kothawade.sa...@gmail.com> wrote:
>>>>
>>>>>
>>>>>
>>>>> >> Could you please explain how can use xterm command : xterm --tn
>>>>> dumb -cm -dc -e this is your command
>>>>>Fustratigly, xterm is not present in remote  machine and I am not
>>>>> allowed to install xterm utility on targeted remote machine. Still, is
>>>>> there any way to run it through ansible conroller?
>>>>>
>>>>>
>>>>> On Saturday, 18 April 2020 14:45:18 UTC+5:30, Samir Kothawade wrote:
>>>>>>
>>>>>> Hi,
>>>>&

Re: [ansible-project] Re: How to change remote hosts' terminal screen size/resolution in Ansible

2020-04-18 Thread Karl Auer
TERM=dumb

Sorry, I mistyped. The minus sign should have been an equals sign.

The idea is to set the environment variable TERM to the value "dumb"
immediately before starting the shell in which your program will be run.

Also can you please answer the question about whether you can redirect the
output of this program?

I strongly suggest you experiment manually rather than with Ansible. You
need to find out how to achieve what you want, then duplicate that in
Ansible. Doing both at once is very painful.

Regards, K.

On Sun, Apr 19, 2020 at 2:34 AM Samir Kothawade 
wrote:

> bash: TERM-dumb: command not found.
>
> gnome-terminal utility not available on remote  machine
>
>
> On Sat, 18 Apr 2020 at 21:53, Karl Auer  wrote:
>
>> You *might* be able to convince the console on the remote system to be a
>> dumb terminal by doing this as your command:
>>
>> TERM-dumb ; sh -c your_command
>>
>> This works in gnome-terminal as well - it seems to suppress most control
>> sequences except CR/LF and similar.
>>
>> Or in Ansible, setting the environment variable TERM to "dumb" then
>> running your command in a new shell. In my experiments here, when I set
>> TERM=dumb and ran sh from within a console or from within gnome-terminal,
>> the colourisation went away. However the console still had a fixed number
>> of lines.
>>
>> Regards, K.
>>
>> On Sun, Apr 19, 2020 at 1:04 AM Samir Kothawade <
>> kothawade.sa...@gmail.com> wrote:
>>
>>>
>>>
>>> >> Could you please explain how can use xterm command : xterm --tn dumb -cm
>>> -dc -e this is your command
>>>Fustratigly, xterm is not present in remote  machine and I am not
>>> allowed to install xterm utility on targeted remote machine. Still, is
>>> there any way to run it through ansible conroller?
>>>
>>>
>>> On Saturday, 18 April 2020 14:45:18 UTC+5:30, Samir Kothawade wrote:
>>>>
>>>> Hi,
>>>>
>>>> *Here is the brief about scenario: *
>>>>
>>>> 1. login to Debian host machine using ansible
>>>> 2. Go to corresponding directory where the binary is and execute that
>>>> binary. (This binary is written in c and C++. After execution it ask for
>>>> the userid & password)
>>>> 3. After login into that binary's shell, it  has several commands which
>>>> displays statistics. Those stats are lengthy and does not fit in current
>>>> screen resolution. For seen seeing all the stats we have to press Down
>>>> arrow Key or Enter key multiple time until we reach to last stat line.
>>>>
>>>> *How I am doing this: *
>>>>
>>>> *-** hosts: sam*
>>>> *  gather_facts: no*
>>>> *  tasks:*
>>>> *  - name: capture all stats*
>>>> *ignore_errors: yes*
>>>> *expect:*
>>>> *  command: /opt/abc/xyz_Platform/bin/go_xyz_cli*
>>>> *  responses:*
>>>> *(.*)Username:(.*): "admin"*
>>>> *(.*)Password:(.*): "admin"*
>>>> *(.*)xyz_cli>(.*): display all debug stats*
>>>> *(.*):(.*): ''*
>>>> *register: stats*
>>>> *  - local_action: copy content="{{ stats.stdout}}"
>>>> dest="/home/sam/quickstats/stats.txt"*
>>>> *ignore_errors: yes*
>>>>
>>>>
>>>> *Issues Facing : *
>>>>
>>>> 1. Multiple similar line gets copied in stats.txt file when above
>>>> reaches to ==>>*  (.*):(.*): ''*  (See above code section marked in
>>>> blue). Using this method to press  key.
>>>> 2. Actual stats counts are of line 500 hundred but above code returns
>>>> 2k + stats with repetitive stats and some garbage values appended.
>>>> 3. If i removes this  portion *  (.*):(.*): ''*  from code, then above
>>>> script only copies 20-30 lines which currently are displayed on screen or
>>>> which displayed in current screen size.
>>>>
>>>>
>>>> I guess I can achieve this by changing remote servers' screen size. but
>>>> I could not able to get any such way in ansible.
>>>>
>>>>
>>>> May I request you to help me in this ?
>>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Ansible Project" group.
>>> To unsubscribe from this group

Re: [ansible-project] Re: How to change remote hosts' terminal screen size/resolution in Ansible

2020-04-18 Thread Karl Auer
You *might* be able to convince the console on the remote system to be a
dumb terminal by doing this as your command:

TERM-dumb ; sh -c your_command

This works in gnome-terminal as well - it seems to suppress most control
sequences except CR/LF and similar.

Or in Ansible, setting the environment variable TERM to "dumb" then running
your command in a new shell. In my experiments here, when I set TERM=dumb
and ran sh from within a console or from within gnome-terminal, the
colourisation went away. However the console still had a fixed number of
lines.

Regards, K.

On Sun, Apr 19, 2020 at 1:04 AM Samir Kothawade 
wrote:

>
>
> >> Could you please explain how can use xterm command : xterm --tn dumb -cm
> -dc -e this is your command
>Fustratigly, xterm is not present in remote  machine and I am not
> allowed to install xterm utility on targeted remote machine. Still, is
> there any way to run it through ansible conroller?
>
>
> On Saturday, 18 April 2020 14:45:18 UTC+5:30, Samir Kothawade wrote:
>>
>> Hi,
>>
>> *Here is the brief about scenario: *
>>
>> 1. login to Debian host machine using ansible
>> 2. Go to corresponding directory where the binary is and execute that
>> binary. (This binary is written in c and C++. After execution it ask for
>> the userid & password)
>> 3. After login into that binary's shell, it  has several commands which
>> displays statistics. Those stats are lengthy and does not fit in current
>> screen resolution. For seen seeing all the stats we have to press Down
>> arrow Key or Enter key multiple time until we reach to last stat line.
>>
>> *How I am doing this: *
>>
>> *-** hosts: sam*
>> *  gather_facts: no*
>> *  tasks:*
>> *  - name: capture all stats*
>> *ignore_errors: yes*
>> *expect:*
>> *  command: /opt/abc/xyz_Platform/bin/go_xyz_cli*
>> *  responses:*
>> *(.*)Username:(.*): "admin"*
>> *(.*)Password:(.*): "admin"*
>> *(.*)xyz_cli>(.*): display all debug stats*
>> *(.*):(.*): ''*
>> *register: stats*
>> *  - local_action: copy content="{{ stats.stdout}}"
>> dest="/home/sam/quickstats/stats.txt"*
>> *ignore_errors: yes*
>>
>>
>> *Issues Facing : *
>>
>> 1. Multiple similar line gets copied in stats.txt file when above reaches
>> to ==>>*  (.*):(.*): ''*  (See above code section marked in blue). Using
>> this method to press  key.
>> 2. Actual stats counts are of line 500 hundred but above code returns 2k
>> + stats with repetitive stats and some garbage values appended.
>> 3. If i removes this  portion *  (.*):(.*): ''*  from code, then above
>> script only copies 20-30 lines which currently are displayed on screen or
>> which displayed in current screen size.
>>
>>
>> I guess I can achieve this by changing remote servers' screen size. but I
>> could not able to get any such way in ansible.
>>
>>
>> May I request you to help me in this ?
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/2f760261-f3ca-420b-86a5-d9eb2ed85206%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/2f760261-f3ca-420b-86a5-d9eb2ed85206%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 

*Karl Auer* { manager, systems support }
P: 1300 759 975
E: ka...@2pisoftware.com
2pisoftware.com

GPG/PGP : DF6A 43E5 FB9D D884 C6CA CD7F 5278 212D E80F C107
Previous: 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08SQ_etTQUJ%2BfTYMb1Jn-u-rd8m4BTJBnaoFhOf%2BL70Fbg%40mail.gmail.com.


Re: [ansible-project] Re: How to change remote hosts' terminal screen size/resolution in Ansible

2020-04-18 Thread Karl Auer
What shell are you using on the remote machine? And what kind of terminal
is it running in? I have a suspicion that it is just running on a pty, and
that your program is blindly putting out control sequences. If it is, then
there's nothing you can do about it except strip them using regexp or
similar.

Is there any way to redirect the output from your program into a file? That
bypasses the terminal stuff completely , though as I said, if your program
is blindly colourising its output OR blindly waiting after every 24 lines,
there's nothing much you can do about it. The duplicate output is strange -
can you provide a sample? It may be the program trying to output bold text
or something.

Right about now I would be contacting the people responsible for a) the
Debian host and b) this program you are trying to run to see if there is
some way to solve this problem neatly.

Were you able to find out about possible additional command line controls
on the program? Anything Ansible can do, you can do too, so try manually
logging in and seeing what you can find out.

Regards, K.


On Sun, Apr 19, 2020 at 1:04 AM Samir Kothawade 
wrote:

>
>
> >> Could you please explain how can use xterm command : xterm --tn dumb -cm
> -dc -e this is your command
>Fustratigly, xterm is not present in remote  machine and I am not
> allowed to install xterm utility on targeted remote machine. Still, is
> there any way to run it through ansible conroller?
>
>
> On Saturday, 18 April 2020 14:45:18 UTC+5:30, Samir Kothawade wrote:
>>
>> Hi,
>>
>> *Here is the brief about scenario: *
>>
>> 1. login to Debian host machine using ansible
>> 2. Go to corresponding directory where the binary is and execute that
>> binary. (This binary is written in c and C++. After execution it ask for
>> the userid & password)
>> 3. After login into that binary's shell, it  has several commands which
>> displays statistics. Those stats are lengthy and does not fit in current
>> screen resolution. For seen seeing all the stats we have to press Down
>> arrow Key or Enter key multiple time until we reach to last stat line.
>>
>> *How I am doing this: *
>>
>> *-** hosts: sam*
>> *  gather_facts: no*
>> *  tasks:*
>> *  - name: capture all stats*
>> *ignore_errors: yes*
>> *expect:*
>> *  command: /opt/abc/xyz_Platform/bin/go_xyz_cli*
>> *  responses:*
>> *(.*)Username:(.*): "admin"*
>> *(.*)Password:(.*): "admin"*
>> *(.*)xyz_cli>(.*): display all debug stats*
>> *(.*):(.*): ''*
>> *register: stats*
>> *  - local_action: copy content="{{ stats.stdout}}"
>> dest="/home/sam/quickstats/stats.txt"*
>> *ignore_errors: yes*
>>
>>
>> *Issues Facing : *
>>
>> 1. Multiple similar line gets copied in stats.txt file when above reaches
>> to ==>>*  (.*):(.*): ''*  (See above code section marked in blue). Using
>> this method to press  key.
>> 2. Actual stats counts are of line 500 hundred but above code returns 2k
>> + stats with repetitive stats and some garbage values appended.
>> 3. If i removes this  portion *  (.*):(.*): ''*  from code, then above
>> script only copies 20-30 lines which currently are displayed on screen or
>> which displayed in current screen size.
>>
>>
>> I guess I can achieve this by changing remote servers' screen size. but I
>> could not able to get any such way in ansible.
>>
>>
>> May I request you to help me in this ?
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/2f760261-f3ca-420b-86a5-d9eb2ed85206%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/2f760261-f3ca-420b-86a5-d9eb2ed85206%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 

*Karl Auer* { manager, systems support }
P: 1300 759 975
E: ka...@2pisoftware.com
2pisoftware.com

GPG/PGP : DF6A 43E5 FB9D D884 C6CA CD7F 5278 212D E80F C107
Previous: 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08SY0hyWapjMvWv%3DGFx92QDZVyZT1Fk59S0MBrbDnRN%2Bkw%40mail.gmail.com.


Re: [ansible-project] Re: How to change remote hosts' terminal screen size/resolution in Ansible

2020-04-18 Thread Karl Auer
How exactly are the stats output on the host?

If the programs that produce them send them to standard output, then one
option would be to run the commands and redirect their outputs to a file.
When all the programs have been run, copy that file to wherever you need
it. Remember to append for all but the first command.

Also, I don't understand what you mean about *(.*):(.*): ''*

A better mechanism (IMHO) would be to write a shell script that generates
all the stats in the order you want them, and either have that script write
to a file or redirect its output to a file. Then just grab that file. If
the stats are to be obtained from multiple machines you could copy the
script to each with Ansible and then execute it. If it's just one host, you
could leave the script on that host. It depends on where would be the most
appropriate place to maintain the script.

Regards, K.




On Sat, Apr 18, 2020 at 7:50 PM Samir Kothawade 
wrote:

> Also, There is a limitation on remote host - It does not have xrandr
> module. So, changing screen size with xrandr will not be  available :(
>
> On Saturday, 18 April 2020 14:45:18 UTC+5:30, Samir Kothawade wrote:
>>
>> Hi,
>>
>> *Here is the brief about scenario: *
>>
>> 1. login to Debian host machine using ansible
>> 2. Go to corresponding directory where the binary is and execute that
>> binary. (This binary is written in c and C++. After execution it ask for
>> the userid & password)
>> 3. After login into that binary's shell, it  has several commands which
>> displays statistics. Those stats are lengthy and does not fit in current
>> screen resolution. For seen seeing all the stats we have to press Down
>> arrow Key or Enter key multiple time until we reach to last stat line.
>>
>> *How I am doing this: *
>>
>> *-** hosts: sam*
>> *  gather_facts: no*
>> *  tasks:*
>> *  - name: capture all stats*
>> *ignore_errors: yes*
>> *expect:*
>> *  command: /opt/abc/xyz_Platform/bin/go_xyz_cli*
>> *  responses:*
>> *(.*)Username:(.*): "admin"*
>> *(.*)Password:(.*): "admin"*
>> *(.*)xyz_cli>(.*): display all debug stats*
>> *(.*):(.*): ''*
>> *register: stats*
>> *  - local_action: copy content="{{ stats.stdout}}"
>> dest="/home/sam/quickstats/stats.txt"*
>> *ignore_errors: yes*
>>
>>
>> *Issues Facing : *
>>
>> 1. Multiple similar line gets copied in stats.txt file when above reaches
>> to ==>>*  (.*):(.*): ''*  (See above code section marked in blue). Using
>> this method to press  key.
>> 2. Actual stats counts are of line 500 hundred but above code returns 2k
>> + stats with repetitive stats and some garbage values appended.
>> 3. If i removes this  portion *  (.*):(.*): ''*  from code, then above
>> script only copies 20-30 lines which currently are displayed on screen or
>> which displayed in current screen size.
>>
>>
>> I guess I can achieve this by changing remote servers' screen size. but I
>> could not able to get any such way in ansible.
>>
>>
>> May I request you to help me in this ?
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/1ee2dc0f-11c5-4644-b1fb-dec87ade59ed%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/1ee2dc0f-11c5-4644-b1fb-dec87ade59ed%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 

*Karl Auer* { manager, systems support }
P: 1300 759 975
E: ka...@2pisoftware.com
2pisoftware.com

GPG/PGP : DF6A 43E5 FB9D D884 C6CA CD7F 5278 212D E80F C107
Previous: 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08QCC3hzXjPPcyfYoRygtC0GzwWMiKhUqxOJ18F-UmiSKQ%40mail.gmail.com.


Re: [ansible-project] telnet issue

2020-04-13 Thread Karl Auer
Unless you have some specific reason for wanting to use telnet, the obvious
workaround is to use ssh instead

Regards, K.


On Mon, Apr 13, 2020 at 5:51 PM Zaldy B  wrote:

> Hi Karl,
>
> yes, I can connect to the device from my ansible server using telnet.  I
> can also connect to the device using my putty (outside of ansible) using
> telnet.
>
>
>
> On Monday, April 13, 2020 at 3:23:36 AM UTC-4, Karl Auer wrote:
>>
>> Can you connect to your IOS devices normally, i.e. outside Ansible?
>>
>> If yes, then I have no idea what's going on, but if not, get that working
>> first before you try doing it with Ansible.
>>
>> Off the cuff theory is that the devices do not permit telnet
>> connections...
>>
>> Regards, K.
>>
>>
>> On Mon, Apr 13, 2020 at 5:07 PM Zaldy B  wrote:
>>
>>> Hi Experts,
>>>
>>> I am just new with this one. I am trying to connect using telnet (ssh
>>> has no issue) to my IOS devices, but I am getting error when I run my
>>> playbook:
>>> --
>>>
>>>-
>>>
>>>name: Telnet do show version for IOS
>>>hosts: telnet_device
>>>gather_facts: false
>>>connection: local
>>>
>>>tasks:
>>>- name: show version
>>>   telnet:
>>>   user: cisco
>>>   password: cisco
>>>   login_prompt: "Username: "
>>>   prompts:
>>>   - "[>#]"
>>>   command:
>>>   - terminal length 0
>>>   - show version
>>>
>>> Error:
>>> PLAY [Telnet do show version for IOS]
>>> ***
>>>
>>> TASK [show version]
>>> *
>>> fatal: [telnet_device]: FAILED! => {"changed": true, "msg": "Telnet
>>> action failed: telnet connection closed", "output": []}
>>>
>>> PLAY RECAP
>>> **
>>> telnet_device : ok=0 changed=0 unreachable=0 failed=1 skipped=0
>>> rescued=0 ignored=0
>>>
>>>
>>>
>>> Any suggestions/comments is much appreciated.
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Ansible Project" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to ansible...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/ansible-project/60dd5a69-5a23-4c53-9bcf-08e5e8df6b44%40googlegroups.com
>>> <https://groups.google.com/d/msgid/ansible-project/60dd5a69-5a23-4c53-9bcf-08e5e8df6b44%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>
>>
>> --
>>
>> *Karl Auer* { manager, systems support }
>> P: 1300 759 975
>> E: ka...@2pisoftware.com
>> 2pisoftware.com
>>
>> GPG/PGP : DF6A 43E5 FB9D D884 C6CA CD7F 5278 212D E80F C107
>> Previous: 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/77abad3c-b5ad-45c5-a2e2-d5e8331f73b6%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/77abad3c-b5ad-45c5-a2e2-d5e8331f73b6%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 

*Karl Auer* { manager, systems support }
P: 1300 759 975
E: ka...@2pisoftware.com
2pisoftware.com

GPG/PGP : DF6A 43E5 FB9D D884 C6CA CD7F 5278 212D E80F C107
Previous: 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08TUa3W5ge7VsP%2BgtL0ciq%3DJMSNDMsbrZbpn48quZCVpeQ%40mail.gmail.com.


Re: [ansible-project] telnet issue

2020-04-13 Thread Karl Auer
Can you connect to your IOS devices normally, i.e. outside Ansible?

If yes, then I have no idea what's going on, but if not, get that working
first before you try doing it with Ansible.

Off the cuff theory is that the devices do not permit telnet connections...

Regards, K.


On Mon, Apr 13, 2020 at 5:07 PM Zaldy B  wrote:

> Hi Experts,
>
> I am just new with this one. I am trying to connect using telnet (ssh has
> no issue) to my IOS devices, but I am getting error when I run my playbook:
> --
>
>-
>
>name: Telnet do show version for IOS
>hosts: telnet_device
>gather_facts: false
>connection: local
>
>tasks:
>- name: show version
>   telnet:
>   user: cisco
>   password: cisco
>   login_prompt: "Username: "
>   prompts:
>   - "[>#]"
>   command:
>   - terminal length 0
>   - show version
>
> Error:
> PLAY [Telnet do show version for IOS]
> ***
>
> TASK [show version]
> *
> fatal: [telnet_device]: FAILED! => {"changed": true, "msg": "Telnet action
> failed: telnet connection closed", "output": []}
>
> PLAY RECAP
> **
> telnet_device : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0
> ignored=0
>
>
>
> Any suggestions/comments is much appreciated.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/60dd5a69-5a23-4c53-9bcf-08e5e8df6b44%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/60dd5a69-5a23-4c53-9bcf-08e5e8df6b44%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 

*Karl Auer* { manager, systems support }
P: 1300 759 975
E: ka...@2pisoftware.com
2pisoftware.com

GPG/PGP : DF6A 43E5 FB9D D884 C6CA CD7F 5278 212D E80F C107
Previous: 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08R-n_mPcN1H_B8WtbYUakJ-daszsA4v7BnztF0WFH0dRA%40mail.gmail.com.


Re: [ansible-project] Re: Newbie query

2020-04-03 Thread Karl Auer
creation of a TXT record on Route53. I
> am having issues with the playbook and decided to
> > strip it right back to a basic invocation:
> >
> > ansible -vvv -m "route53" -a 'ttl=3600  aws_secret_key='secret' zone=
> xxx.net <http://xxx.net>
> > record=_acme-challenge.aaa.yyy.xxx.net <
> http://acme-challenge.aaa.yyy.xxx.net>  retry_interval=500
> > private_zone=False state=present type=TXT wait_timeout=300 wait=True
> aws_access_key='key'
> > value=VK1_axFJiaazkF0eaz6erW9VebwrNqko8PvaHHte1EM ' localhost
> >
> > Route53 is expecting the value enclosed in " " - no matter how I
> encapsulate the value I get the same error:
> >
> >
> > localhost | FAILED! => {
> > "changed": false,
> > "invocation": {
> > "module_args": {
> > "alias": null,
> > "alias_evaluate_target_health": false,
> > "alias_hosted_zone_id": null,
> > "aws_access_key": "key",
> > "aws_secret_key": "secret",
> > "ec2_url": null,
> > "failover": null,
> > "health_check": null,
> > "hosted_zone_id": null,
> > "identifier": null,
> > "overwrite": null,
> > "private_zone": false,
> > "profile": null,
> > "record": "_acme-challenge.aaa.bbb.ccc.net <
> http://acme-challenge.aaa.bbb.ccc.net>",
> > "region": null,
> > "retry_interval": 500,
> > "security_token": null,
> > "state": "present",
> > "ttl": 3600,
> > "type": "TXT",
> > "validate_certs": true,
> > "value": [
> > "VK1_axFJiaazkF0eaz6erW9VebwrNqko8PvaHHte1EM"
> > ],
> > "vpc_id": null,
> > "wait": true,
> > "wait_timeout": 300,
> > "weight": null,
> > "zone": "ccc.net <http://ccc.net>"
> > }
> > },
> > "msg": "[Invalid Resource Record: FATAL problem:
> InvalidCharacterString (Value should be enclosed in quotation
> > marks) encountered with
> 'VK1_axFJiaazkF0eaz6erW9VebwrNqko8PvaHHte1EM']"
> > }
> >
> >
> > What am I doing wrong ?
> >
> > Thanks
> >
> > Andy
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups "Ansible Project" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an email to
> > ansible-project+unsubscr...@googlegroups.com  ansible-project+unsubscr...@googlegroups.com>.
> > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/ansible-project/ddfda090-6fa5-40d4-a537-c09b47eca130%40googlegroups.com
> > <
> https://groups.google.com/d/msgid/ansible-project/ddfda090-6fa5-40d4-a537-c09b47eca130%40googlegroups.com?utm_medium=email&utm_source=footer
> >.
>
>
> --
> Ecommerce and Linux consulting + Perl and web application programming.
> Debian and Sympa administration. Provisioning with Ansible.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/3d7117be-1e85-6e2f-d01e-d63ef5f0be60%40linuxia.de
> .
>


-- 

*Karl Auer* { manager, systems support }
P: 1300 759 975
E: ka...@2pisoftware.com
2pisoftware.com

GPG/PGP : DF6A 43E5 FB9D D884 C6CA CD7F 5278 212D E80F C107
Previous: 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08RU1LkKss3mtpqkFo_APG_OU3capk2RSH7Wrg%2BcPC59aQ%40mail.gmail.com.


Re: [ansible-project] Re: ternary clarification needed

2020-03-26 Thread Karl Auer
> Whenever a ternary is used are both conditions evaluated regardless ?


A ternary filter consists of three parts:

a) the condition
b) the statement to be evaluated if the condition is true
c) the statement to be evaluted if the condition is false.
Only one of b) and c) will be evaluated, but the condition will always be
evaluated IF the ternary statement itself is evaluated.

Regards, K.

On Thu, Mar 26, 2020 at 6:02 PM Davide Scrimieri 
wrote:

>
> UPDATE: PLEASE, DISCARD what I said about the when statement at the end of
> my post, in my original code I had a typo, and was not working for other
> reasons. The first part of the post about the ternary statement still stands
>
>
> On Thursday, March 26, 2020 at 7:54:58 AM UTC+1, Davide Scrimieri wrote:
>>
>> Hello,
>>
>> Whenever a ternary is used are both conditions evaluated regardless ?
>>
>> For example, I want to convert "my_other_var" to an object only if it is
>> passed as as string, otherwise I don't want to touch the object, and leave
>> it as it is.
>>
>> - set_fact:
>> my_var: "{{  ( my_other_var | type_debug == 'str' ) | ternary
>> (my_other_var | from_json, my_other_var }}"
>>
>> What happens right now is this:
>>
>> if my_other_var is str -> It works
>> if my_other_var is dict -> it gives me the error saying that my_other_var
>> should be a string to be converted from_json. But I would expect that being
>> the condition on the left = False, it would ignore the left condition on
>> the ternary and only consider the rightmost condition.
>>
>> I also tried using when:
>>
>> -- name: Set fact for string  object
>>   set_fact:
>>  my_var: "{{ my_other_var | from_json }}"
>>   when: (my_other_var | type_debug == 'str')
>>
>>
>> - name: Set fat for dict  object
>>   set_fact:
>> my_var: "{{ my_other_var | from_json }}"
>>   when: (my_other_var | type_debug == 'dict')
>>
>> However, if "my_other_var" is dict, the first block (named set fact for
>> string object) gives me the same error as before. I was actually expecting
>> that being the when statement equals to false, it would simply ignore it.
>>
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/3e0c7994-6e18-44bb-afc5-807607fa2a88%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/3e0c7994-6e18-44bb-afc5-807607fa2a88%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 

*Karl Auer* { manager, systems support }
P: 1300 759 975
E: ka...@2pisoftware.com
2pisoftware.com

GPG/PGP : DF6A 43E5 FB9D D884 C6CA CD7F 5278 212D E80F C107
Previous: 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08Q2W5f9OZXdgdLBDHZYW8WmpyDW%3D2%3Dw1wu45kz2ji%3DE5Q%40mail.gmail.com.


Re: [ansible-project] Creating a AWS VPC with IPv6 addresses

2020-03-13 Thread Karl Auer
I haven't tried this myself, but what happens if you just provide iPv6
addresses to the ec2_vpc_net module?

The "initial /56" is just the CIDR block, I'd have thought, same as with
IPv4. But as I say I have not tried this.

Regards, K.

On Sat, Mar 14, 2020 at 5:33 AM Ralf Weber  wrote:

> Moin!
>
> I wanted to use ansible to create a VPC with Amazon supplied IPv6
> addresses. In the Console this is an option, when I create and VPC, but
> I could not find anything in ec2_vpc_net for that.
>
> When I use ec2_vpc_net_info I see the IPv6 association of the other VPCs
> I created manually, and I see that ec2_vpc_subnet has the ability to let
> instances get and IPv6 address, but that needs to be specified out of
> the /56 that normally is assigned from Amazon per VPC.
>
> What is missing is the initial option to create the /56 for the VPC or
> am I missing something?
>
> TIA and so long
> -Ralf
> ——-
> Ralf Weber
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/E71C3D85-C61C-4AE6-B4A7-C92403B5D57F%40fl1ger.de
> .
>


-- 

*Karl Auer* { manager, systems support }
P: 1300 759 975
E: ka...@2pisoftware.com
2pisoftware.com

GPG/PGP : 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E
Previous: 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08RnBR_AGMaQde9L1hw%3DyrTcN_gPpfejAUjhkfp-YY8WZg%40mail.gmail.com.


Re: [ansible-project] How to replace all occurrences of '_' by '-' in all keys of a YAML complex object

2020-02-27 Thread Karl Auer
Are you seeking to change only LHS literals in declarations, or do you need
to change such literals in arbitrary other locations in your YAML?

Basically, any tool for making the change you want needs to be able to
clearly identify where the change is needed and where not - for example,
NOT in the RHS (values) of the declarations in your examples.

If you have a relatively small number of keys that need changing, you could
simply process them all by name using something like sed:

   change key_1 to key-1
   change key_2 to key-2
   change _key_3 to _key-3

and so on. You might be able to do something more heroic with sed, but in
my experince simple sed is best.

If you have too many target keys to do this, then you will need a
programmatic solution rather than a declarative solution (I think).

There may well be a tool out there that understands YAML and can perform
transforms on it - it would be worth spending a bit of time looking for one
before you work on your own solution. There are definitely tools for
working with JSON (jq for example). You may be able to convert YAML to
JSON, do the transforms with a JSON-capable tool, then convert back to
YAML. A quick flirt with Google suggests that there are a great many
converters, some online and some not.

If you do decide to do it yourself, it is probably untimately simplest to
use Python or some other language with good JSON-handling libraries.

Regards, K.

On Fri, Feb 28, 2020 at 2:13 AM jean-christophe manciot <
actionmysti...@gmail.com> wrote:

> For instance, let's consider the following YAML data:
>   - key_1: '$.*?/|\^(){}+@[]&_-'
> key_2:
>   - '$.*?/|\^(){}+@[]&_-'
>   - "{\_}"
>   - value23
> key_3: value31
> key_4:
>   - value41
>   - value42
> key_5: value51
>   - key_1_: value12
> _key_2:
>   - value24
>   - value25
> key__3: '$.*?/|\^(){}+@[]&_-'
> key_5___: value52
>
>
> The goal is:
>
> - to replace all '_' from the keys into '-', except for the first
> character which may be a '_';
>
> - all values must remain untouched
>
> - the name and number of the keys are variable
>
> - the depth of "recursiveness" is variable and unlimited
>
>
> For instance here, the translation would result as:
>   - key-1: '$.*?/|\^(){}+@[]&_-'
> key-2:
>   - '$.*?/|\^(){}+@[]&_-'
>   - "{\_}"
>   - value23
> key-3: value31
> key-4:
>   - value41
>   - value42
> key-5: value51
>   - key-1-: value12
> _key-2:
>   - value24
>   - value25
> key--3: '$.*?/|\^(){}+@[]&_-'
> key-5---: value52
>
> Any suggestion?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/000d7d79-ddbe-45c9-89c4-2eef73979b2f%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/000d7d79-ddbe-45c9-89c4-2eef73979b2f%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 

*Karl Auer* { manager, systems support }
P: 1300 759 975
E: ka...@2pisoftware.com
2pisoftware.com

GPG/PGP : 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E
Previous: 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08R5PRxyEozeDg1sDwr1gTCPt7S_T8QstmKf3r5ABBK9dA%40mail.gmail.com.


Re: [ansible-project] Create Key value pair

2020-02-24 Thread Karl Auer
Hi. We need to know *specifically* what you are trying to do. Not generally.

Create a minimal playbook that implements (or at least tries to implement)
your goal. When you've got as far as you can, run it and postthe playbook
and the output in full here.
In FULL.

Anything else is wasting your time and ours.

Right now this looks to me as if you are a student trying to get someone
else to do your homework.

Regards, K.

On Tue, Feb 25, 2020 at 12:59 AM Sivaraman P 
wrote:

> Hi, I just want to
>
> Ex:
>  hosts: dev
>  tasks:
>- name: get variable
>  shell: some command
>  register: out1 # i want to use stdout_lines of these out1 in my next
> task
>
>- name: export
>  shell: command {{item}}
>  register: out2 # i want to use stdout kines of each item in my next
> task
>  with_items: "{{out1.stdout_lines}}"
>
> #After this I tried to combine out1 as key and out2 as value to the key,
> But I am getting error
>
>   - set_fact:
>   my_env: "{{my_env | default ({}) | combine ({{item.0}}:
> {{item.1}})}}"
> with_nested:
>- "{{out1.stdout_lines}}"
>- "{{out2 | json_query('results[*].stdout_lines}}"
>
> On Mon, 24 Feb 2020, 19:12 Dick Visser,  wrote:
>
>> Hi Sivaraman
>>
>> Could you please state clearly:
>>
>> - What goal you are trying to achieve.
>> - How you are doing this.
>> - What problems you encounter.
>> - Which command did you run, and what actual output did you get from
>> that (copied as plain text - not as images, attachments, or
>> screenshots)
>> - What the relevant tasks/playbooks/code/variables look like.
>>
>>
>>
>> On Mon, 24 Feb 2020 at 14:07, Sivaraman P 
>> wrote:
>> >
>> > I have list of items to be executed in the command and I have to save
>> the result in stdout for each item to the same item.
>> >
>> > Ex:
>> >  hosts: dev
>> >  tasks:
>> >- name: get variable
>> >  shell: cat file #this file contain the list of items that I need
>> to run the command
>> >  register: out1
>> >
>> >- name: export
>> >  shell: command {{item}}
>> >  register: out2 #This contains results of each item from out1.
>> >  with_items: "{{out1.stdout_lines}}"
>> >
>> > The question is I have to get the stdout of each item result and I have
>> to store as value for that item.
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> Groups "Ansible Project" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> an email to ansible-project+unsubscr...@googlegroups.com.
>> > To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/16eb196f-324c-4944-ac21-94c1a0b98e75%40googlegroups.com
>> .
>>
>>
>>
>> --
>> Dick Visser
>> Trust & Identity Service Operations Manager
>> GÉANT
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Ansible Project" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to ansible-project+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/CAL8fbwMvo6%2BF0ZJJNgDO3UNjTCw6d%3D4jFRDncHFvpn19MkcXAg%40mail.gmail.com
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAHS7Q%2BvOU-tkbKtFVGgt5YeY%2BQb4y7dXxVKwJOH6_YjOFZoR-g%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CAHS7Q%2BvOU-tkbKtFVGgt5YeY%2BQb4y7dXxVKwJOH6_YjOFZoR-g%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>


-- 

*Karl Auer* { manager, systems support }
P: 1300 759 975
E: ka...@2pisoftware.com
2pisoftware.com

GPG/PGP : 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E
Previous: 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08QuPV7-ZA-%3DV5DC6T36v_-pTpeqEiPZjDDMzcO0Kn%2BCUA%40mail.gmail.com.


Re: [ansible-project] how to get specified order of strings in list ?

2020-02-09 Thread Karl Auer
Do you want to extract the strings from the comment, or do you just want to
get the three attributes (last_name, mid_name etc) in some particular order?

You can get the parts of the name out of the comment by using the split()
filter. This assumes no names contain spaces or whatever split delimiter
you use - not a good assumption. Ask Charles de Gaulle.

There is no automatable way to reliably work out what order the parts of a
name should be in. Some cultures are firstname, lastname, some are lastname
firstname, some are one in some circumstances and the other way in other
circumstances, some routinely have three parts, or only one part. Even in
the English-speaking world there are zillions of exceptions like J. Edgar
Hoover or Fred Smith Junior.

Regards, K


On Mon, Feb 10, 2020 at 2:34 PM Eric Chang  wrote:

> I have a list like this
>
> user:
>   name: chchang
>   comment: "Chang Chic Hung"
>
> and I want to add more attrs like
>
> last_name: Chang
> mid_name: Chic
>
> but how to get the specifed order of the values ?
> I try  to use filter "first" , but it just return "C" , the first letter ,
> not the first word.
>
> any suggestions ?
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/cd62f864-de01-4d5c-8829-47607bd5b626%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/cd62f864-de01-4d5c-8829-47607bd5b626%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 

*Karl Auer* { manager, systems support }
P: 1300 759 975
E: ka...@2pisoftware.com
2pisoftware.com

GPG/PGP : 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E
Previous: 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08Q8bo5SyBGnW_GkHtTJKDnoGdzk%2BOexhC7Q7-bzt%3DA8ow%40mail.gmail.com.


Re: [ansible-project] Re: can someone please explain about "undefined" error

2020-01-24 Thread Karl Auer
To expand on what Eric said:

Your when: condition refers to a variable called "update_count".

At the point where you refer to it, that variable does not exist. I bolded
the bits of the error message that really matter:

TASK [reboot if required] **

**
task path: /etc/ansible/windows-playbook/copied.yml:22
*fatal*: [EC2AMAZ-9M186EG.corp.medqia.com]: FAILED! => {
"msg": "The conditional check 'update_count.reboot_required' failed.
The error was: error while evaluating conditional
(update_count.reboot_required): *'update_count' is undefined*\n\n.\n\nThe
offending line appears to be:\n\n  tasks:\n   - name: reboot if required\n
   ^ here\n"
}

Common reasons for this error include:
- you misspelled it
- you got the CaPiTaLiSaTiOn wrong
- you defined it after first reference
- you defined it for a host other than EC2AMAZ-9M186EG.corp.medqia.com
- you defined it in a vars file that is not being loaded
- you defined it in a vars file that is not being referenced
- you defined it somewhere where it cannot be referenced
- you rearranged your code and accidentally moved the definition to after
the first reference
- update_count is a field or element of something bigger you forgot to
reference first
- you didn't define it at all

If you'd like more help, post the ENTIRE playbook here (or make it
available in e.g. pastebin). Don't post anything confidential though.

Please post code in a fixed-width font so we can see the indentation.

Regards, K.

On Sat, Jan 25, 2020 at 12:24 AM 'Eric Hymowitz' via Ansible Project <
ansible-project@googlegroups.com> wrote:

> At the risk of being rude, I'm not sure what you don't understand.
>
> You're querying a hash variable update_count , and looking for the member
> named reboot_required .  Where did you define this variable?  If you don't
> define a variable, then the variable is undefined.
>
> Is there more to this playbook that you didn't provide?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/5c5985b8-32a6-4334-aa09-c0e8814af823%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/5c5985b8-32a6-4334-aa09-c0e8814af823%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 

*Karl Auer* { manager, systems support }
P: 1300 759 975
E: ka...@2pisoftware.com
2pisoftware.com

GPG/PGP : 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E
Previous: 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08RC00nc_zFqQSboYEkXASjPSSkEhqnfdzh%3DikH8Obnx3Q%40mail.gmail.com.


Re: [ansible-project] How can I get Ansible to only use Python 3.6?

2019-12-10 Thread Karl Auer
I'm not being nasty when I say this, but:

Prove it :-)

Seriously - the single most likely reason for what you are seeing is that
the users are different. Not the githubuser - the user that is executing
the git command. So prove to yourself that they are in fact the same, e.g.
by setting a variable in the global config for the user you think is being
used, then using the git_config module to display the values being used by
Ansible...

Regards, K.


On Tue, Dec 10, 2019 at 8:57 PM Gyalgin Sherpa  wrote:

> Hello K,
> Yes same user while cloning and executing playbook
>
> Best
>
> On Tue, Dec 10, 2019 at 04:47 Karl Auer  wrote:
>
>> You may be missing the point of Stefan's question. Is Ansible executing
>> this git command as the SAME USER that you are executing the git command
>> as, when you execute the command manually?
>>
>> Authentication for git is user-based. If Ansible is not running the
>> command as the SAME USER that you are using when you run the command
>> manually, then you can expect authentication to fail. By the way, the user
>> that Ansible is running git as is NOT necessarily the user that is running
>> Ansible.
>>
>> A quick look at the Ansible docs reveals a git_config module. You could
>> try using it to retrieve the global git configuration (the equivalent of
>> running git config --global -l) via Ansible on the target host. Does the
>> output match what you get when you execute that command manually on the
>> target host? If not, you have found the problem.
>>
>> Regards, K.
>>
>> On Tue, Dec 10, 2019 at 8:17 PM Gyalgin Sherpa 
>> wrote:
>>
>>> Hello Racke,
>>>
>>> Thank you for the quick response. My apologies for hijacking the loop,
>>> this my first email will make a new   Subject line going forward.
>>> Coming back to my issue, yes I was successfully clone in my target
>>> machine where ansible is installed . But when I target same location with
>>> following line in ansible playbook, it’s prompting me password
>>>
>>> Best Regards
>>>
>>> On Tue, Dec 10, 2019 at 04:10 Stefan Hornburg (Racke) 
>>> wrote:
>>>
>>>> On 12/10/19 10:05 AM, Gyalgin Sherpa wrote:
>>>> > Hello team,
>>>> > It’s asking me user and password while  checking code from giit
>>>> > git:
>>>> >   repo; ‘git url’
>>>> >   dest : ‘local path’
>>>> >
>>>> > But when I clone manually it does not prompt for password,
>>>> >
>>>> > Best Regards
>>>> >
>>>>
>>>> Hello Gyalgin,
>>>>
>>>> it is really so hard to start a fresh email instead of hijacking the
>>>> subject and providing more than next to nothing
>>>> information about your problem?
>>>>
>>>> Did you try to clone the Git repo manually on the target system as the
>>>> same user as Ansible?
>>>>
>>>> Regards
>>>>  Racke
>>>>
>>>> > On Tue, Dec 10, 2019 at 03:15 Stefan Hornburg (Racke) <
>>>> ra...@linuxia.de <mailto:ra...@linuxia.de>> wrote:
>>>> >
>>>> > On 12/9/19 10:30 PM, Mark Bolden wrote:
>>>> > > I am on Centos 7 and I was trying to install Pyrax and seeing
>>>> these errors:
>>>> > >
>>>> > > ERROR: os-service-types 1.7.0 has requirement
>>>> pbr!=2.1.0,>=2.0.0, but you'll have pbr 1.10.0 which is incompatible.
>>>> > > ERROR: python-keystoneclient 3.22.0 has requirement
>>>> pbr!=2.1.0,>=2.0.0, but you'll have pbr 1.10.0 which is
>>>> > incompatible.
>>>> > > ERROR: python-keystoneclient 3.22.0 has requirement
>>>> requests>=2.14.2, but you'll have requests 2.6.0 which is
>>>> > incompatible.
>>>> > > ERROR: oslo-config 6.12.0 has requirement requests>=2.18.0, but
>>>> you'll have requests 2.6.0 which is incompatible.
>>>> > > ERROR: stevedore 1.31.0 has requirement pbr!=2.1.0,>=2.0.0, but
>>>> you'll have pbr 1.10.0 which is incompatible.
>>>> > >
>>>> > >
>>>> > > So, I Installed Python 3.6 and ran pip3 install pyrax and
>>>> success! The problem seems to be that ansible-playbook is
>>>> > > still looking at Python 2.7 which does NOT have the pyrax
>>>> module installed be

Re: [ansible-project] How can I get Ansible to only use Python 3.6?

2019-12-10 Thread Karl Auer
gt;> > <mailto:ansible-project+unsubscr...@googlegroups.com > ansible-project%2bunsubscr...@googlegroups.com>>.
>> > > To view this discussion on the web visit
>> > >
>> https://groups.google.com/d/msgid/ansible-project/6b5c8efe-0e1c-4728-9217-2894220268a4%40googlegroups.com
>> > >
>> > <
>> https://groups.google.com/d/msgid/ansible-project/6b5c8efe-0e1c-4728-9217-2894220268a4%40googlegroups.com?utm_medium=email&utm_source=footer
>> >.
>> >
>> >
>> > --
>> > Ecommerce and Linux consulting + Perl and web application
>> programming.
>> > Debian and Sympa administration. Provisioning with Ansible.
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> Groups "Ansible Project" group.
>> > To unsubscribe from this group and stop receiving emails from it,
>> send an email to
>> > ansible-project+unsubscr...@googlegroups.com > ansible-project%2bunsubscr...@googlegroups.com>.
>> > To view this discussion on the web visit
>> >
>> https://groups.google.com/d/msgid/ansible-project/49a16888-ce7d-7945-d253-ac62d1643bd9%40linuxia.de
>> .
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> Groups "Ansible Project" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> an email to
>> > ansible-project+unsubscr...@googlegroups.com > ansible-project+unsubscr...@googlegroups.com>.
>> > To view this discussion on the web visit
>> >
>> https://groups.google.com/d/msgid/ansible-project/CABynDMHLje1D1AbBNk1zz5ZpGLU%3DCX268f3gLp%2Bb6706QHJ%3DSA%40mail.gmail.com
>> > <
>> https://groups.google.com/d/msgid/ansible-project/CABynDMHLje1D1AbBNk1zz5ZpGLU%3DCX268f3gLp%2Bb6706QHJ%3DSA%40mail.gmail.com?utm_medium=email&utm_source=footer
>> >.
>>
>>
>> --
>> Ecommerce and Linux consulting + Perl and web application programming.
>> Debian and Sympa administration. Provisioning with Ansible.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Ansible Project" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to ansible-project+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/479feb36-586f-6f35-3bae-eafd93859e99%40linuxia.de
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CABynDMGDR3z-uNzYMJRnHVv4-6_UFupDk3wB7AE6O5c0oMQ%3DnA%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CABynDMGDR3z-uNzYMJRnHVv4-6_UFupDk3wB7AE6O5c0oMQ%3DnA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>


-- 

*Karl Auer* { manager, systems support }
P: 1300 759 975
E: ka...@2pisoftware.com
2pisoftware.com

GPG/PGP : 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E
Previous: 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08SCgcE0TTm3RKzmZVjMWQq-hTJwQekP_%3Dwv2HgPByKAww%40mail.gmail.com.


Re: [ansible-project] How to use cloud-init to customize a windows virtual machine in oracle cloud on first boot using ansible

2019-11-26 Thread Karl Auer
So - what is your actual question?

I suggest you start with an extremely simple userdata script that does
something simple like create a file.

If you select at the launched instance in the AWS Console instance list,
you can view the userdata using Actions -> Instance Settings -> View/Change
User Data. This is a good way to check that your Ansible play did create an
instance with userdata supplied, and to check that the userdata it supplied
is what you expected.

If the above shows that Ansible is providing userdata to the instance, the
next step is to check whether your userdata was executed at launch time.
You can retrieve the system log of your launched instance by selecting the
instance in the AWS Console instance list and then Actions -> Instance
Settings -> Get System Log. If your userdata script did not run correctly,
you should see error messages in this log.

Let us know how you go.

Regards, K.


On Tue, Nov 26, 2019 at 9:01 PM Rahul Rawat  wrote:

> Yes, it's the same question.
> We just want when windows instance created using oci-ansible-modules from
> ansible role. On first boot, I have powershell script which should be run
> automatically.
> Powershell script should be invoke or run through cloud-init/user_data.
>
> I have an idea about ansibe role and oci-ansible-modules. But new in
> cloud-init and user_data script.
>
> Here is my main task ansible playbook which create VM in oracle cloud.
>
> ---
> # tasks file for oci-create-vm
> - name: Create VM
>   oci_instance:
> availability_domain: "{{ availability_domain }}"
> compartment_id: "{{ compartment_id }}"
> name: "{{ name }}"
> image_id: "{{ image_id }}"
> shape: "{{ shape }}"
> vnic:
> assign_public_ip: True
> hostname_label: "{{ instance_hostname }}"
> subnet_id: "{{ subnet_id }}"
> metadata:
> user_data: "{{ lookup('file', '{{ user_data_path }}' ) }}"
>   delegate_to: localhost
>   register: oci_result
>
> regards,
> Rahul
>
> On Tuesday, November 26, 2019 at 3:12:33 PM UTC+5:30, Karl Auer wrote:
>>
>> Is this the same question you asked a week or so ago? If so, I think we
>> need more detail.
>>
>> cloud-init happens on launch. Under some circumstances, it can happen on
>> boot as well.
>>
>>
>> https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ec2-windows-user-data.html
>>
>> Not sure what you mean by running powershell "with the help of cloud-init
>> using ansible role"...
>>
>> Regards, K.
>>
>>
>> On Tue, Nov 26, 2019 at 8:28 PM Rahul Rawat  wrote:
>>
>>> Hi,
>>>
>>> I have created VM using oci-ansible-modules on oracle cloud. Now, I want
>>> to run powershell script on first boot with the use of cloud-init using
>>> ansible.
>>>
>>> Means when my playbook run from ansible role,
>>> Firstly, VM create using oci-anisble-module and
>>> secondly, powershell run with the help of cloud-init using ansible role.
>>>
>>> regards,
>>> Rahul Rawat
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Ansible Project" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to ansible...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/ansible-project/f056dc25-1768-4c7e-bddd-63c1777f192a%40googlegroups.com
>>> <https://groups.google.com/d/msgid/ansible-project/f056dc25-1768-4c7e-bddd-63c1777f192a%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>
>>
>> --
>>
>> *Karl Auer* { manager, systems support }
>> P: 1300 759 975
>> E: ka...@2pisoftware.com
>> 2pisoftware.com
>>
>> GPG/PGP : 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E
>> Previous: 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/920aab87-2bd2-4933-a764-623c835fbd39%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/920aab87-2bd2-4933-a764-623c835fbd39%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 

*Karl Auer* { manager, systems support }
P: 1300 759 975
E: ka...@2pisoftware.com
2pisoftware.com

GPG/PGP : 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E
Previous: 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08SY-uYnJoe0giQUR_fOGvAwirZWPFPd13xi%2By%2BRPpCbvQ%40mail.gmail.com.


Re: [ansible-project] How to use cloud-init to customize a windows virtual machine in oracle cloud on first boot using ansible

2019-11-26 Thread Karl Auer
Is this the same question you asked a week or so ago? If so, I think we
need more detail.

cloud-init happens on launch. Under some circumstances, it can happen on
boot as well.

https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ec2-windows-user-data.html

Not sure what you mean by running powershell "with the help of cloud-init
using ansible role"...

Regards, K.


On Tue, Nov 26, 2019 at 8:28 PM Rahul Rawat  wrote:

> Hi,
>
> I have created VM using oci-ansible-modules on oracle cloud. Now, I want
> to run powershell script on first boot with the use of cloud-init using
> ansible.
>
> Means when my playbook run from ansible role,
> Firstly, VM create using oci-anisble-module and
> secondly, powershell run with the help of cloud-init using ansible role.
>
> regards,
> Rahul Rawat
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/f056dc25-1768-4c7e-bddd-63c1777f192a%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/f056dc25-1768-4c7e-bddd-63c1777f192a%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 

*Karl Auer* { manager, systems support }
P: 1300 759 975
E: ka...@2pisoftware.com
2pisoftware.com

GPG/PGP : 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E
Previous: 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08TWBTpFTimzfjRMJ3t6DYi_H8Gc1V1sQWN-mQ0kvH15Ew%40mail.gmail.com.


Re: [ansible-project] Need to use the cloud-init option to have it run the PowerShell script that enables WinRM. Use of cloud-init

2019-11-21 Thread Karl Auer
Hullo Rahul.

What is your actual question? There is extensive documentation in AWS on
how to set up user data to do stuff on launch.

If you just need to do a few simple things, you can do it directly in the
user data script. If your needs are more complicated, write a script that
looks in a well-known location for other scripts, and executes them.

The way we do it is that we have a standard userdata script that sets up
some useful variables, clones a repo out of CodeCommit, then runs all the
scripts in the repo.  It's a little more complicated, but that's the
general idea. If your scripts rarely change you could deliver them with the
AMI. We use the repo so that our scripts are (mostly) independent of the
AMI.

For winrm specifically you could also probably enable it via a group policy.

Regards, K.

On Thu, Nov 21, 2019 at 9:34 PM Rahul Rawat  wrote:

> Hi,
>
> I have used oci-ansible-modules to create VM on oracle cloud.
> Now, I need to use cloud-init to enable winrm on boot.
>
> regards,
> Rahul Rawat
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/f2427937-ced6-4696-93ab-d8391f6d5f42%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/f2427937-ced6-4696-93ab-d8391f6d5f42%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 

*Karl Auer* { manager, systems support }
P: 1300 759 975
E: ka...@2pisoftware.com
2pisoftware.com

GPG/PGP : 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E
Previous: 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08S5DMZwKkycWufqJA15qT%3DmRnSK9yRc7QiOaG4By7Wq0w%40mail.gmail.com.


Re: [ansible-project] mapping AWS 'Username' tag to ansible_user inventory var?

2019-11-19 Thread Karl Auer
This is one of AWS' stranger choices, having different default usernames on
different distros of the same operating system. Imagine if you got
"Administrator" on Windows 7, "Admin" on Windows 8, and "Root" on
Windows10...

I can't help you with the vars, but here are some oter ideas:

If you bake your own AMIs, the simplest solution by far is to set up your
own user on the AMIs you bake. The only special things about the default
users are that they have the private ssh key in ~/.ssh, they are in the
sudoers file, they are able to do passwordless sudo, and they are in a
particular set of groups. Setting up  a user of your own with a well-known
name common to all your instances can be done in userdata quite easily.
It's a security benefit too - especially if you take the default user OUT
of the sudoers file. Also, it is rapidly and painfully obvious if an
instance has not been based on one of your own AMIs. A related method would
be to change the user on one distro to be the same as the user on the
other, e.g., change all your "ubuntu" users to be called "ec2-user". Half
the effort :-)

Assuming you don't change the usernames, then an alternative that I like
because it is dynamic, is to attempt to access an instance using first one,
then the other username. Whichever one works is the right one for that
instance :-) I confess though that I have not implemented that in Ansible,
just in various utility scripts.

A third alternative, also only possible if you bake your own AMIs, is to
make sure that an OS identifier is in the AMI name. Then you can figure out
what the OS is dynamically, even on a stopped instance, by getting the
instance details and checking the AMI name. I have a script that sets up my
~/.ssh/config file with entries for every instance, and it decides whether
to set the user parameter to ubuntu or ec2-user based on AMI info in the
instance descriptions.

A fourth alternative - also simple to do in userdata - is to have each
instance "phone home" as it launches. For example, if you have a webserver
somewhere you could have your new Ubuntu instances use curl to request
https://domain?HiIAmUbuntuAt10.10.100.12 or whatever, while your Centos
instances request https://domain?HiIAmCentosAt_11.11.102.15. It'll stand
out nicely in your webserver logs. The nice thing about this solution is
that you can dump almost unlimited amounts of info out of the instance like
that - anything the instance can know, it can communicate.

If you really want to go old-school (not to mention a bit secret squirrel),
use ping with the -p option, and send 0x for Ubuntu and 0x4343 for
Centos to a listener somewhere. Or send 85-byte packets from Ubuntu and
67-byte packets from Centos :-)

Regards, K.





On Wed, Nov 20, 2019 at 12:45 AM Dick Visser  wrote:

> Hi
>
> I'm using the ec2.py dynamic inventory, and this appears to work well.
> My deployment consists of several different distros, and so the
> ansible_user is different across the instances.
> While instantiating from different AMI, I am adding a "Username" tag
> to the instances.
> I then include a second inventory, to map these:
>
> # Map usernames
> [tag_Username_ubuntu:vars]
> ansible_user=ubuntu
>
> [tag_Username_admin:vars]
> ansible_user=admin
>
> [tag_Username_admin:centos]
> ansible_user=centos
>
>
> This works fine, but I wonder if there is a way to do without this extra
> file.
> Basically I'm looking to populate ansible_user from the last part of
> the tag_Username_ubuntu/admin/etc.
> Some kind of regex replacement, or...?
>
> thanks :)
>
>
> --
> Dick Visser
> Trust & Identity Service Operations Manager
> GÉANT
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAL8fbwN2-Q0LetJxrMtv-1%3DjpQZDB%3D9%2BuJtkfCaSfM2V2%2BOqhQ%40mail.gmail.com
> .
>


-- 

*Karl Auer* { manager, systems support }
P: 1300 759 975
E: ka...@2pisoftware.com
2pisoftware.com

GPG/PGP : 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E
Previous: 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08RkB-v3ii8d4qWLYtUM-upfPzUNP7W1aiHpY5V6id3t-A%40mail.gmail.com.


Re: [ansible-project] Hanging on SSH connection

2019-10-24 Thread Karl Auer
Unreachability due to connection refused or unroutability will fail
relatively quickly. Unreachability due to a filter dropping packets can
hang for a very long time.

Since a manual ssh works, you know for a fact that the mechanics of it all
are sound. Did you duplicate the command being used in Ansible? If not,
that would be the next step.

Is the command being used to access the new servers literally character for
character identical in every respect with the command being used to access
the old servers?

Any commonality between the older servers, not shared by the new ones, is a
possible culprit.

Regards, K.

On Fri, Oct 25, 2019 at 2:33 AM Thomas Lawrence  wrote:

> I have tried with brand new servers and a backup of one of the older
> servers. The only thing I haven't done is take a fresh backup and try that,
> which I may try tomorrow. The OSs are different as the servers are running
> an out of date OS, that I will have to upgrade at some point!
>
> Ansible won't even connect outside of the script, to the new servers. All
> the old ones work fine. Unfortunately, if there is something I need to
> change to allow ansible to work, the sys admin neglected to include it in
> the docs he wrote!
>
> Manual connection via SSH does work.
>
> I don't think the IP is wrong as I have checked it. When the IP is wrong
> and it can't actually connect, I get an error back saying it is
> unreachable. In this scenario it hangs and gives no feedback.
>
>
>
> On Thursday, 24 October 2019 16:00:54 UTC+1, Karl Auer wrote:
>>
>> Are the servers using the same base setup as the old ones? If the other
>> servers are not Ubuntu 19.04, try using the same OS as the older servers to
>> see if there is an OS difference getting in your way.
>>
>> Have you made any changes to the scripts? I.e., has anything changed in
>> the setup? By the way - even if you are tempted to answer "no", rest
>> assured something has, or it would be working :-)
>>
>> Does a manual connection via ssh work?
>>
>> The single commonest reason for an ssh connection hanging (rather than
>> failing) is that the connection is is to the wrong IP address. The latter
>> can be the effect of a DNS issue, too. Second most common is a filter
>> stopping ssh getting through. Third most common is that ssh is asking for
>> input somewhere the user can't see it.
>>
>> ssh can ask for several kinds of input - not just passwords. It may ask
>> you to confirm connection to a new host, confirm that you want to connect
>> to a host whose key seems to have change, or prompt you for a passphrase.
>> The first two of those can be switched off with client-side options as you
>> have done with one of them with StrictHostKeyChecking=no (it's bad
>> practice to do so, but in an automated setting perhaps necessary).
>>
>> Regards, K.
>>
>>
>> On Fri, Oct 25, 2019 at 1:03 AM Thomas Lawrence 
>> wrote:
>>
>>> I have inherited the job of continuing with my organisation's ansible
>>> setup after our sys admin left. I am having a hell of a job adding new
>>> server to the setup as ansible can not seem to connect to any newly created
>>> servers.
>>>
>>> In the below example, I have a brand new server running Ubuntu 19.04.
>>> Ansible asks me for the password as expected and I provide it, but nothing
>>> seems to happen.
>>>
>>> ansible -vvv [IP] -m ping -u root --ask-pass
>>>
>>> I get the following output from the command:
>>>
>>> <[IP]> ESTABLISH SSH CONNECTION FOR USER: root
>>> <[IP]> SSH: EXEC sshpass -d9 ssh -C -o ControlMaster=auto -o
>>> ControlPersist=60s -o StrictHostKeyChecking=no -o User=root -o
>>> ConnectTimeout=10 -o ControlPath=/home/tom/.ansible/cp/2827bd34c0 [IP]
>>> '/bin/sh -c '"'"'echo ~root && sleep 0'"'"''
>>>
>>> It will happily it there for ages with nothing happening until I abort
>>> the command and I am at a loss as to what to try next.
>>>
>>> This document and any attachments to it contain information that is
>>> private and confidential and should only be read by those persons to whom
>>> they are addressed. No person, without subsequent written confirmation of
>>> their contents, should rely upon the contents of this e-mail. This e-mail
>>> and the information it contains are supplied in good faith but Remote Media
>>> shall not be under any liability in damages or otherwise for any reliance
>>> that may be placed upon them by the recipi

Re: [ansible-project] luks_device module questions

2019-10-24 Thread Karl Auer
*Please provide the entire playbook, or at least the plays above and below
the one where you think the syntax error is. And provide it in a monospace
typeface.*

We can probably help with a syntax problem. But not if we can't see your
playbook.

Regards, K.

On Fri, Oct 25, 2019 at 1:52 AM Test Acct  wrote:

> I was using the group page. I typed it out within my vi editor on my
> server.  I have checked for tabs or weird spacing, all around that module
> and the ones before it. I did that first, since I had issues when i first
> pasted my play.  I have been running the check version of the playbook.  I
> got the same issue on both types of run.
>
> Is there better guidance or tutorial on the luks_device module?  For now I
> have just done raw: command instead. but I had hoped to use the luks module
> to improve upon and actually use my playbook effectively.  I'd even like to
> use the crypttab module as well for this section.
>
> - J
>
> On Thursday, October 24, 2019 at 10:38:36 AM UTC+1, Karl Auer wrote:
>>
>> If it's a syntax error, then it has nothing to do with the specific
>> modules you are using or their parameters; it has to do with the text of
>> the playbook only. You can use the -C option to ansible-playbooks to ensure
>> that the playbook doesn't actually DO anything. If it ever gets to the
>> point of trying, you know your syntax is good :-)
>>
>> Syntax errors are often not where Ansible says they are; Ansible can only
>> tell you where it was up to when it noticed the error. So please provide
>> the entire playbook, or at least the plays above and below the one where
>> you think the syntax error is.
>>
>> Also, paste your sample code using a monospace typeface to preserve its
>> indentation. Zillions of syntax errors in Ansible are caused by bad
>> indenting. Here is your snippet, properly formatted for this mailing list:
>>
>> - name: create luks device named Vol0
>>   luks_device:
>>  device: "/dev/VolGroup0"
>>  state: "present"
>>  name: "Vol0"
>>  keyfile: "/root/luks.key"
>>
>> If you are using a text-only mailer, consider using an HTML-capable
>> mailer at least for posting code.
>>
>> You will save yourself grief if you always quote strings, even when it is
>> not strictly necessary.
>>
>> Regards, K.
>>
>> On Thu, Oct 24, 2019 at 8:24 PM Test Acct  wrote:
>>
>>> Hello.
>>> I am trying to create encrypted logical volumes within my playbook. I
>>> have the process written out, via commands (as if i were doing each one
>>> individually).
>>> I have gotten the LVM portion in the playbook working. I had found the
>>> luks_device and crypttab modules to try to use.  I have not been able to
>>> get them to work, using the documentation examples.  Is there someone who
>>> can assist or tutor these modules and help me break down my commands into
>>> the playbook via these modules?  Currently, I keep getting syntax errors
>>> when doing
>>> - name: create luks device named Vol0
>>>   luks_device:
>>>  device: "/dev/VolGroup0"
>>>  state: "present"
>>>  name: "Vol0"
>>>  keyfile: "/root/luks.key"
>>>
>>> It's stating the error is at the -name portion... I have checked for tab
>>> spaces, etc.  I have also tried without the quotation marks. Any assistance
>>> would be wonderful.
>>>
>>> Thanks
>>>
>>> J
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Ansible Project" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to ansible...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/ansible-project/87305df9-d5c0-41c2-8ecb-9dc5d2e7e839%40googlegroups.com
>>> <https://groups.google.com/d/msgid/ansible-project/87305df9-d5c0-41c2-8ecb-9dc5d2e7e839%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>
>>
>> --
>>
>> *Karl Auer* { manager, systems support }
>> P: 1300 759 975
>> E: ka...@2pisoftware.com
>> 2pisoftware.com
>>
>> GPG/PGP : 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E
>> Previous: 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" grou

Re: [ansible-project] Hanging on SSH connection

2019-10-24 Thread Karl Auer
Are the servers using the same base setup as the old ones? If the other
servers are not Ubuntu 19.04, try using the same OS as the older servers to
see if there is an OS difference getting in your way.

Have you made any changes to the scripts? I.e., has anything changed in the
setup? By the way - even if you are tempted to answer "no", rest assured
something has, or it would be working :-)

Does a manual connection via ssh work?

The single commonest reason for an ssh connection hanging (rather than
failing) is that the connection is is to the wrong IP address. The latter
can be the effect of a DNS issue, too. Second most common is a filter
stopping ssh getting through. Third most common is that ssh is asking for
input somewhere the user can't see it.

ssh can ask for several kinds of input - not just passwords. It may ask you
to confirm connection to a new host, confirm that you want to connect to a
host whose key seems to have change, or prompt you for a passphrase. The
first two of those can be switched off with client-side options as you have
done with one of them with StrictHostKeyChecking=no (it's bad practice to
do so, but in an automated setting perhaps necessary).

Regards, K.


On Fri, Oct 25, 2019 at 1:03 AM Thomas Lawrence  wrote:

> I have inherited the job of continuing with my organisation's ansible
> setup after our sys admin left. I am having a hell of a job adding new
> server to the setup as ansible can not seem to connect to any newly created
> servers.
>
> In the below example, I have a brand new server running Ubuntu 19.04.
> Ansible asks me for the password as expected and I provide it, but nothing
> seems to happen.
>
> ansible -vvv [IP] -m ping -u root --ask-pass
>
> I get the following output from the command:
>
> <[IP]> ESTABLISH SSH CONNECTION FOR USER: root
> <[IP]> SSH: EXEC sshpass -d9 ssh -C -o ControlMaster=auto -o
> ControlPersist=60s -o StrictHostKeyChecking=no -o User=root -o
> ConnectTimeout=10 -o ControlPath=/home/tom/.ansible/cp/2827bd34c0 [IP]
> '/bin/sh -c '"'"'echo ~root && sleep 0'"'"''
>
> It will happily it there for ages with nothing happening until I abort the
> command and I am at a loss as to what to try next.
>
> This document and any attachments to it contain information that is
> private and confidential and should only be read by those persons to whom
> they are addressed. No person, without subsequent written confirmation of
> their contents, should rely upon the contents of this e-mail. This e-mail
> and the information it contains are supplied in good faith but Remote Media
> shall not be under any liability in damages or otherwise for any reliance
> that may be placed upon them by the recipient.
>
> Any form of reproduction, dissemination, copying, disclosure,
> modification, distribution and/or publication of this e-mail is strictly
> prohibited save unless expressly authorised by the sender. Signagelive is
> a registered trademark of Remote Media Group Limited which is registered in
> England and Wales under number 3924279.
>
> For more information, please see our Privacy Policy
> <https://signagelive.com/privacy-policy/> or GDPR
> <https://signagelive.com/gdpr/> information page.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/6b98f1dd-6dc6-4d5d-84a3-c05f34b8f6c8%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/6b98f1dd-6dc6-4d5d-84a3-c05f34b8f6c8%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 

*Karl Auer* { manager, systems support }
P: 1300 759 975
E: ka...@2pisoftware.com
2pisoftware.com

GPG/PGP : 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E
Previous: 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08Q_fgtpzKX%2B432JU7TSpXzcZ59vOo2qgfqpkBfeqsna2A%40mail.gmail.com.


Re: [ansible-project] luks_device module questions

2019-10-24 Thread Karl Auer
If it's a syntax error, then it has nothing to do with the specific modules
you are using or their parameters; it has to do with the text of the
playbook only. You can use the -C option to ansible-playbooks to ensure
that the playbook doesn't actually DO anything. If it ever gets to the
point of trying, you know your syntax is good :-)

Syntax errors are often not where Ansible says they are; Ansible can only
tell you where it was up to when it noticed the error. So please provide
the entire playbook, or at least the plays above and below the one where
you think the syntax error is.

Also, paste your sample code using a monospace typeface to preserve its
indentation. Zillions of syntax errors in Ansible are caused by bad
indenting. Here is your snippet, properly formatted for this mailing list:

- name: create luks device named Vol0
  luks_device:
 device: "/dev/VolGroup0"
 state: "present"
 name: "Vol0"
 keyfile: "/root/luks.key"

If you are using a text-only mailer, consider using an HTML-capable mailer
at least for posting code.

You will save yourself grief if you always quote strings, even when it is
not strictly necessary.

Regards, K.

On Thu, Oct 24, 2019 at 8:24 PM Test Acct  wrote:

> Hello.
> I am trying to create encrypted logical volumes within my playbook. I have
> the process written out, via commands (as if i were doing each one
> individually).
> I have gotten the LVM portion in the playbook working. I had found the
> luks_device and crypttab modules to try to use.  I have not been able to
> get them to work, using the documentation examples.  Is there someone who
> can assist or tutor these modules and help me break down my commands into
> the playbook via these modules?  Currently, I keep getting syntax errors
> when doing
> - name: create luks device named Vol0
>   luks_device:
>  device: "/dev/VolGroup0"
>  state: "present"
>  name: "Vol0"
>  keyfile: "/root/luks.key"
>
> It's stating the error is at the -name portion... I have checked for tab
> spaces, etc.  I have also tried without the quotation marks. Any assistance
> would be wonderful.
>
> Thanks
>
> J
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/87305df9-d5c0-41c2-8ecb-9dc5d2e7e839%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/87305df9-d5c0-41c2-8ecb-9dc5d2e7e839%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 

*Karl Auer* { manager, systems support }
P: 1300 759 975
E: ka...@2pisoftware.com
2pisoftware.com

GPG/PGP : 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E
Previous: 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08TF5Btc5iDmJ8Va8w4-oBDNznZeAXkfYmnvbK5B5mkY0A%40mail.gmail.com.


Re: [ansible-project] unable to copy ansible vriable into file

2019-10-15 Thread Karl Auer
The error is telling you exactly what the problem is. You need to work out
what might be causing that problem.

In this case, a list object does not have an attribute called (in Unicode)
'0'.

Your loop uses values from a sequence, and the first in the sequence is
'0'. This is used to dereference the variable result.results (as in,
result.results[item]...).

I'm guessing that result.results is an empty list, OR maybe you should cast
item to be an integer:

{{ result.results[item |int].container.Config.Hostname }}

One option would be to output result in a debug statement before you try to
use it, so you can look at its structure and then dereference it properly.

BTW this is guesswork. I haven't read any doco or tested any of the above.

Regards, K.

On Tue, Oct 15, 2019 at 7:19 PM abhay srivastava <
abhaysrivastav...@gmail.com> wrote:

>
>
> Error:
>
> TASK [lineinfile]
> ***
> fatal: [192.168.1.158]: FAILED! => {"msg": "The task includes an option
> with an undefined variable. The error was: 'list object' has no attribute
> u'0'\n\nThe error appears to be in
> '/home/cloud/nidhi/ccepbook/nidhi-playbook.yml': line 31, column 5, but
> may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe
> offending line appears to be:\n\n\n  - local_action: lineinfile line=\"{{
> result.results[item].container.Config.Hostname }}\"
> dest=/tmp/abhay.csv\n^ here\nWe could be wrong, but this one looks like
> it might be an issue with\nmissing quotes. Always quote template expression
> brackets when they\nstart a value. For instance:\n\nwith_items:\n
> - {{ foo }}\n\nShould be written as:\n\nwith_items:\n  - \"{{ foo
> }}\"\n"}
>
>
>   - local_action: lineinfile line="{{
> result.results[item].container.Config.Hostname }}" dest=/tmp/abhay.csv
> with_sequence: start=0 end="{{ count|int }}"
>
>
> here count is from 0 to 2
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/2f0e435f-64c5-4550-8ad6-f56731c2007c%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/2f0e435f-64c5-4550-8ad6-f56731c2007c%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 

*Karl Auer* { manager, systems support }
P: 1300 759 975
E: ka...@2pisoftware.com
2pisoftware.com

GPG/PGP : 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E
Previous: 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08Tef9UWHuKuJ841otOUSN7YMTt_5xGZY9EeMc87EQxSsg%40mail.gmail.com.


Re: [ansible-project] Manual VS Ansible playbook in window server

2019-10-10 Thread Karl Auer
I know NOTHING about Windows, but maybe if you read the doco for the
setup.exe program it might have some clues? Also, what output do you get if
you replace all the arguments to setup.exe with one "/?"

Regards, K.


On Thu, Oct 10, 2019 at 7:08 PM Manish Kumar 
wrote:

> yes it is ignoring  the command passed after -s  . Is there any option to
> debug and pin point the actual issue as it is working fine without ansible .
>
> On Wednesday, October 9, 2019 at 6:32:18 PM UTC+5:30, Karl Auer wrote:
>>
>> Dunno about it now throwing an error, but that space is not in the input
>> either, i.e., it is not in the command as you provided it here. And why
>> would it not be in the output? Ansible doesn't randomly remove bits of
>> output. Might be worth double-checking...
>>
>> Regards, K.
>>
>>
>> On Wed, Oct 9, 2019 at 11:50 PM Manish Kumar 
>> wrote:
>>
>>> yes space is there but in output it is not visible . Also It does not
>>> throw any error .
>>>
>>> On Wednesday, October 9, 2019 at 6:19:12 PM UTC+5:30, Karl Auer wrote:
>>>>
>>>> Is there supposed to be a space after "-f1" or "-f2"? It does look like
>>>> there should be one, but that's just a wild guess.
>>>>
>>>> Regards, K.
>>>>
>>>>
>>>> On Wed, Oct 9, 2019 at 10:49 PM Manish Kumar 
>>>> wrote:
>>>>
>>>>> Dear All,
>>>>>
>>>>> Below task gets completed while running it manually from  window dos
>>>>> however nothing happens while we execute it using ansible playbook and
>>>>> there is no error as well.
>>>>>
>>>>> How to debug such issue and get it working ?
>>>>>
>>>>> Play-book1:
>>>>> ---
>>>>> - name: install Disribution Server
>>>>>   gather_facts: false
>>>>>   hosts: win
>>>>>
>>>>>   tasks:
>>>>> - name: Install services
>>>>>   win_psexec:
>>>>>command:
>>>>> D:\Software_InstallationSets\NT_Service_Installset\RepSrv\SETUP.EXE -s
>>>>> -f1D:\Software_InstallationSets\NT_Service_Installset\RepSrv\Repsrv.iss
>>>>> -f2D:\ArisGlobal\Components\RepSrv_Iss.log
>>>>>
>>>>> Play-book2:
>>>>> ---
>>>>> - name: install Disribution Server
>>>>>   gather_facts: false
>>>>>   hosts: win
>>>>>
>>>>>   tasks:
>>>>> - name: Install services
>>>>>   win_command:
>>>>> D:\Software_InstallationSets\NT_Service_Installset\RepSrv\SETUP.EXE -s
>>>>> -f1D:\Software_InstallationSets\NT_Service_Installset\RepSrv\Repsrv.iss
>>>>> -f2D:\ArisGlobal\Components\RepSrv_Iss.log
>>>>>
>>>>>
>>>>> Output:
>>>>>
>>>>> Host#  ansible-playbook -i inventory.yml install.yml -vvv
>>>>>
>>>>> [WARNING] Ansible is in a world writable directory
>>>>> (/U01/automation/playbooks), ignoring it as an ansible.cfg source.
>>>>>
>>>>> ansible-playbook 2.4.6.0
>>>>>
>>>>>   config file = /etc/ansible/ansible.cfg
>>>>>
>>>>>   configured module search path =
>>>>> [u'/home/tsadmin/.ansible/plugins/modules',
>>>>> u'/usr/share/ansible/plugins/modules']
>>>>>
>>>>>   ansible python module location =
>>>>> /usr/lib/python2.7/site-packages/ansible
>>>>>
>>>>>   executable location = /usr/bin/ansible-playbook
>>>>>
>>>>>   python version = 2.7.16 (default, Jul 19 2019, 23:05:17) [GCC 7.3.1
>>>>> 20180712 (Red Hat 7.3.1-6)]
>>>>>
>>>>> Using /etc/ansible/ansible.cfg as config file
>>>>>
>>>>> Parsed /U01/automation/playbooks/inventory.yml inventory source with
>>>>> ini plugin
>>>>>
>>>>>
>>>>>
>>>>> PLAYBOOK: install.yml
>>>>> **
>>>>>
>>>>> 1 plays in install.yml
>>>>>
>>>>>
>>>>>
>>>>> PLAY [install Disribution Server]
>>>>> **
>>>>>
>>>>> META:

Re: [ansible-project] Manual VS Ansible playbook in window server

2019-10-09 Thread Karl Auer
Dunno about it now throwing an error, but that space is not in the input
either, i.e., it is not in the command as you provided it here. And why
would it not be in the output? Ansible doesn't randomly remove bits of
output. Might be worth double-checking...

Regards, K.


On Wed, Oct 9, 2019 at 11:50 PM Manish Kumar 
wrote:

> yes space is there but in output it is not visible . Also It does not
> throw any error .
>
> On Wednesday, October 9, 2019 at 6:19:12 PM UTC+5:30, Karl Auer wrote:
>>
>> Is there supposed to be a space after "-f1" or "-f2"? It does look like
>> there should be one, but that's just a wild guess.
>>
>> Regards, K.
>>
>>
>> On Wed, Oct 9, 2019 at 10:49 PM Manish Kumar 
>> wrote:
>>
>>> Dear All,
>>>
>>> Below task gets completed while running it manually from  window dos
>>> however nothing happens while we execute it using ansible playbook and
>>> there is no error as well.
>>>
>>> How to debug such issue and get it working ?
>>>
>>> Play-book1:
>>> ---
>>> - name: install Disribution Server
>>>   gather_facts: false
>>>   hosts: win
>>>
>>>   tasks:
>>> - name: Install services
>>>   win_psexec:
>>>command:
>>> D:\Software_InstallationSets\NT_Service_Installset\RepSrv\SETUP.EXE -s
>>> -f1D:\Software_InstallationSets\NT_Service_Installset\RepSrv\Repsrv.iss
>>> -f2D:\ArisGlobal\Components\RepSrv_Iss.log
>>>
>>> Play-book2:
>>> ---
>>> - name: install Disribution Server
>>>   gather_facts: false
>>>   hosts: win
>>>
>>>   tasks:
>>> - name: Install services
>>>   win_command:
>>> D:\Software_InstallationSets\NT_Service_Installset\RepSrv\SETUP.EXE -s
>>> -f1D:\Software_InstallationSets\NT_Service_Installset\RepSrv\Repsrv.iss
>>> -f2D:\ArisGlobal\Components\RepSrv_Iss.log
>>>
>>>
>>> Output:
>>>
>>> Host#  ansible-playbook -i inventory.yml install.yml -vvv
>>>
>>> [WARNING] Ansible is in a world writable directory
>>> (/U01/automation/playbooks), ignoring it as an ansible.cfg source.
>>>
>>> ansible-playbook 2.4.6.0
>>>
>>>   config file = /etc/ansible/ansible.cfg
>>>
>>>   configured module search path =
>>> [u'/home/tsadmin/.ansible/plugins/modules',
>>> u'/usr/share/ansible/plugins/modules']
>>>
>>>   ansible python module location =
>>> /usr/lib/python2.7/site-packages/ansible
>>>
>>>   executable location = /usr/bin/ansible-playbook
>>>
>>>   python version = 2.7.16 (default, Jul 19 2019, 23:05:17) [GCC 7.3.1
>>> 20180712 (Red Hat 7.3.1-6)]
>>>
>>> Using /etc/ansible/ansible.cfg as config file
>>>
>>> Parsed /U01/automation/playbooks/inventory.yml inventory source with ini
>>> plugin
>>>
>>>
>>>
>>> PLAYBOOK: install.yml
>>> **
>>>
>>> 1 plays in install.yml
>>>
>>>
>>>
>>> PLAY [install Disribution Server]
>>> **
>>>
>>> META: ran handlers
>>>
>>>
>>>
>>> TASK [Install services]
>>> 
>>>
>>> task path: /U01/automation/playbooks/install.yml:7
>>>
>>> Using module file
>>> /usr/lib/python2.7/site-packages/ansible/modules/windows/win_psexec.ps1
>>>
>>> <192.140.6.17> ESTABLISH WINRM CONNECTION FOR USER: admin on PORT 5986
>>> TO 192.140.6.17
>>>
>>> EXEC (via pipeline wrapper)
>>>
>>> changed: [192.140.6.17] => {
>>>
>>> "changed": true,
>>>
>>> "delta": "0:00:00.453119",
>>>
>>> "end": "2019-10-09 11:31:36.914910",
>>>
>>> "failed": false,
>>>
>>> "psexec_command": "psexec.exe -accepteula
>>> D:\\Software_InstallationSets\\NT_Service_Installset\\RepSrv\\SETUP.EXE -s
>>> -f1D:\\Software_InstallationSets\\NT_Service_Installset\\RepSrv\\Repsrv.iss
>>> -f2D:\\ArisGlobal\\Components\\RepSrv_Iss.log",
>>>
>>> "rc": 0,
>>>
>>> "start": "2019-10-09 11:31:36.461791",

Re: [ansible-project] Manual VS Ansible playbook in window server

2019-10-09 Thread Karl Auer
Is there supposed to be a space after "-f1" or "-f2"? It does look like
there should be one, but that's just a wild guess.

Regards, K.


On Wed, Oct 9, 2019 at 10:49 PM Manish Kumar 
wrote:

> Dear All,
>
> Below task gets completed while running it manually from  window dos
> however nothing happens while we execute it using ansible playbook and
> there is no error as well.
>
> How to debug such issue and get it working ?
>
> Play-book1:
> ---
> - name: install Disribution Server
>   gather_facts: false
>   hosts: win
>
>   tasks:
> - name: Install services
>   win_psexec:
>command:
> D:\Software_InstallationSets\NT_Service_Installset\RepSrv\SETUP.EXE -s
> -f1D:\Software_InstallationSets\NT_Service_Installset\RepSrv\Repsrv.iss
> -f2D:\ArisGlobal\Components\RepSrv_Iss.log
>
> Play-book2:
> ---
> - name: install Disribution Server
>   gather_facts: false
>   hosts: win
>
>   tasks:
> - name: Install services
>   win_command:
> D:\Software_InstallationSets\NT_Service_Installset\RepSrv\SETUP.EXE -s
> -f1D:\Software_InstallationSets\NT_Service_Installset\RepSrv\Repsrv.iss
> -f2D:\ArisGlobal\Components\RepSrv_Iss.log
>
>
> Output:
>
> Host#  ansible-playbook -i inventory.yml install.yml -vvv
>
> [WARNING] Ansible is in a world writable directory
> (/U01/automation/playbooks), ignoring it as an ansible.cfg source.
>
> ansible-playbook 2.4.6.0
>
>   config file = /etc/ansible/ansible.cfg
>
>   configured module search path =
> [u'/home/tsadmin/.ansible/plugins/modules',
> u'/usr/share/ansible/plugins/modules']
>
>   ansible python module location = /usr/lib/python2.7/site-packages/ansible
>
>   executable location = /usr/bin/ansible-playbook
>
>   python version = 2.7.16 (default, Jul 19 2019, 23:05:17) [GCC 7.3.1
> 20180712 (Red Hat 7.3.1-6)]
>
> Using /etc/ansible/ansible.cfg as config file
>
> Parsed /U01/automation/playbooks/inventory.yml inventory source with ini
> plugin
>
>
>
> PLAYBOOK: install.yml
> **
>
> 1 plays in install.yml
>
>
>
> PLAY [install Disribution Server]
> **
>
> META: ran handlers
>
>
>
> TASK [Install services]
> 
>
> task path: /U01/automation/playbooks/install.yml:7
>
> Using module file
> /usr/lib/python2.7/site-packages/ansible/modules/windows/win_psexec.ps1
>
> <192.140.6.17> ESTABLISH WINRM CONNECTION FOR USER: admin on PORT 5986 TO
> 192.140.6.17
>
> EXEC (via pipeline wrapper)
>
> changed: [192.140.6.17] => {
>
> "changed": true,
>
> "delta": "0:00:00.453119",
>
> "end": "2019-10-09 11:31:36.914910",
>
> "failed": false,
>
> "psexec_command": "psexec.exe -accepteula
> D:\\Software_InstallationSets\\NT_Service_Installset\\RepSrv\\SETUP.EXE -s
> -f1D:\\Software_InstallationSets\\NT_Service_Installset\\RepSrv\\Repsrv.iss
> -f2D:\\ArisGlobal\\Components\\RepSrv_Iss.log",
>
> "rc": 0,
>
> "start": "2019-10-09 11:31:36.461791",
>
> "stderr":
> "D:\\Software_InstallationSets\\NT_Service_Installset\\RepSrv\\SETUP.EXE
> exited with error code 0.\r\n",
>
> "stderr_lines": [
>
>
>   "D:\\Software_InstallationSets\\NT_Service_Installset\\RepSrv\\SETUP.EXE
> exited with error code 0."
>
> ],
>
> "stdout": "\r\nPsExec v2.2 - Execute processes remotely\r\nCopyright
> (C) 2001-2016 Mark Russinovich\r\nSysinternals -
> www.sysinternals.com\r\n\r\n <http://www.sysinternals.com/r/n/r/n>",
>
> "stdout_lines": [
>
> "",
>
> "PsExec v2.2 - Execute processes remotely",
>
> "Copyright (C) 2001-2016 Mark Russinovich",
>
> "Sysinternals - www.sysinternals.com",
>
> ""
>
> ]
>
> }
>
> META: ran handlers
>
> META: ran handlers
>
>
>
> PLAY RECAP
> *
>
> 192.140.6.17   : ok=1changed=1unreachable=0failed=0
>
>
>
> Thanks,
>
> Manish
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsu

Re: [ansible-project] Reduce the No. of script files with same content

2019-10-09 Thread Karl Auer
Instead of having thirteen different script names in the list, have a list
containing the thirteen different filenames. Create a new script
"DeployPackage.script" just like the other thirteen, but have the script
expect a filename as a parameter. Then modify your loop so that it runs the
same script each time, with "item" as a parameter, so that each time
through the loop, DeployPackage.script executes with the next filename from
the list being passed to it.
vars:
   OTHER_DEPLOY_FILENAMES:
 - 'UDI_Data_Model_0.0.104.zip'
 ...etc...
 - 'hotfix-IIS.script'

- name: Executes jmxterm to Install other package
  win_shell: '{{ucmdb_SERVER_JRE_PATH}}java -jar
{{config_PATH}}/jmxterm/{{jmxterm_UBER_JAR}}
-l localhost:29601 -i {{config_PATH}}/jmxterm/DeployPackage.script {{ item
}}'
  with_items:
 - "{{ OTHER_DEPLOY_FILENAMES }}"
This is of course completely untested and I know nothing about how to pass
parameters to your script, but hopefully the above gives you a rough idea.

That "with_items" looks a bit odd, but if it worked for the scripts it will
work for the filenames, I guess.

Regards, K.
On Wed, Oct 9, 2019 at 10:11 PM Uppara venkat 
wrote:

> Hi all,
>
> I have 13 script files in a directory content is same for all the files
> name will be change as below:
> the script file is like this
>
> bean -d UCMDB service=Packaging\ Services
> run deployPackages 1 D:/Software/package UDI_Data_Model_0.0.104.zip 1 1
>
> file name is highlighted this will be change in other files.
> all files are listed   and executing as below;
>
> OTHER_DEPLOY_SCRIPT:
> ['PackageDeploy_UDI_Data_Model_0.0.104.script','PackageDeploy_UDI_Discovery_Base_Enrichment_0.0.104.script','PackageDeploy_UDI_Discovery_Administration_100.
> script','PackageDeploy_UDI_TenantAssociationRules_100.script','PackageDeploy_NormalizationRules_100.script','PackageDeploy_XCDE_Outbound_Adapter_0.0.101.script','PackageDeploy_EMC_ECS-package_0.0.100.script','PackageDeploy_MMiS_Offering_0.0.105.script','PackageDeploy_Database_0.0.100.zip','PackageDeploy_WebService_0.0.101.script','PackageDeploy_hotfix-DDMInfra.script','PackageDeploy_hotfix-QCIM1H126382-v3.script','PackageDeploy_hotfix-IIS.script']
>
> - name: Executes jmxterm to Install other package
>   win_shell: '{{ucmdb_SERVER_JRE_PATH}}java -jar
> {{config_PATH}}/jmxterm/{{jmxterm_UBER_JAR}} -l localhost:29601 -i
> {{config_PATH}}/jmxterm/{{ item }}'
>   with_items:
>  - "{{ OTHER_DEPLOY_SCRIPT }}"
>
>
> My concern is wanted to make single scrip file and the pass the file name
> when it will be executing. Simply to reduce the script files.
>
> Please suggest any methods and  provide examples as well.
>
> Please find the attached script fiiles for your reference.
>
> Best regards,
> Venkat
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAFMhZ_KA3tG1xuATq59FQb-oK3g0VJoe-hvCPrMnayQA2nACLA%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CAFMhZ_KA3tG1xuATq59FQb-oK3g0VJoe-hvCPrMnayQA2nACLA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>


-- 

*Karl Auer* { manager, systems support }
P: 1300 759 975
E: ka...@2pisoftware.com
2pisoftware.com

GPG/PGP : 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E
Previous: 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08RgKLf4rNkOxeOFeSAuAcN3FWyJr81EM9yGopNLQzmxCw%40mail.gmail.com.


Re: [ansible-project] unable to Delete post in GitHub ansible community

2019-09-29 Thread Karl Auer
We are not unsympathetic but

a) any individual in this group who can help you will no doubt make contact

b) if no-one makes contact, it is because no-one in this group can help you

You have done what you can to meet this (IMHO foolish) demand from your
organisation; they can expect no more from you.

And as I and others have pointed out, any damage is long since done.
Removing that post is of no practical use.

Regards, K.


On Sun, Sep 29, 2019 at 4:13 PM Bairava Surya  wrote:

> Hi all,
>
>
> My current organization came to know about this post recently they want me
> to delete it ASAP due to organization regulatory, compliance issue. Can
> anyone help me out I don't want to drag this conversation as problem
> statement is simple and clear.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/7f5e7189-4b68-44d0-852b-1d01b1ceaeda%40googlegroups.com
> .
>


-- 
Karl Auer

Email  : ka...@2pisoftware.com
Website: http://2pisoftware.com

GPG/PGP : 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E
Previous: 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08SzBLLKCp%2BUdzQ3YuDaouj8Zbc8M0VgHEM26eb6raGWHw%40mail.gmail.com.


Re: [ansible-project] unable to Delete post in GitHub ansible community

2019-09-28 Thread Karl Auer
It's too late. The post has been there for days; your request here has
ensured that many, many more people have had a good close look at the post,
just as I now have. The horse has bolted and closing the stable door is
pretty much impossible.

As the saying goes, "security through obscurity is no security".

Concentrating on removing the post is a waste of time. Concentrate instead
on mitigating the loss of the information. If that's even really necessary,
which I confess to being a bit doubtful about.

Regards, K.


On Sun, Sep 29, 2019 at 3:16 AM Bairava Surya  wrote:

> hi team,
>
>
> Due to personal reason i need to delete the post on github ansible
> community as per below URL please tell me process to delete it soon as am
> unable to perform any operation on post .
>
>
> url: https://github.com/ansible/ansible/issues/43404
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/1d634b7f-6de9-4e7b-8ea3-3ac06eb3fd24%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/1d634b7f-6de9-4e7b-8ea3-3ac06eb3fd24%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 
Karl Auer

Email  : ka...@2pisoftware.com
Website: http://2pisoftware.com

GPG/PGP : 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E
Previous: 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08QogDPOb5t66HZDvN5%2B6NB_2Ld0MV5%3Dh1sBN0G5U4HDng%40mail.gmail.com.


Re: [ansible-project] unable to Delete post in GitHub ansible community

2019-09-28 Thread Karl Auer
Hullo there.

I suppose I could be wrong, but it doesn't look to me as if there is
anything in that post that is any kind of problem. If there's some
meaningful credential in there, just change it and move on...

The Internet is forever :-)

Regards, K.


On Sun, Sep 29, 2019 at 3:16 AM Bairava Surya  wrote:

> hi team,
>
>
> Due to personal reason i need to delete the post on github ansible
> community as per below URL please tell me process to delete it soon as am
> unable to perform any operation on post .
>
>
> url: https://github.com/ansible/ansible/issues/43404
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/1d634b7f-6de9-4e7b-8ea3-3ac06eb3fd24%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/1d634b7f-6de9-4e7b-8ea3-3ac06eb3fd24%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 
Karl Auer

Email  : ka...@2pisoftware.com
Website: http://2pisoftware.com

GPG/PGP : 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E
Previous: 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08Ths%2BZXBgaURan-%3D0YQZSdSo-v_tySRREgxzVFk5B5fQQ%40mail.gmail.com.


Re: [ansible-project] Getting error for ".stdout_lines" for a registered variable

2019-09-24 Thread Karl Auer
Post the *complete* output of

- debug:
   var: instid

Posting snippets is useless.


On Wed, Sep 25, 2019 at 3:39 AM Rakesh Parida 
wrote:

> There are 11 items , i will paste the out put of one item, all others are
> similar, or this mail will be lengthy. SO pasting the out put of one item.
>
>  "_ansible_delegated_vars": {
> "ansible_delegated_host": "localhost",
> "ansible_host": "localhost"
> },
> "_ansible_ignore_errors": null,
> "_ansible_item_label": "TOMICS2",
> "_ansible_item_result": true,
> "_ansible_no_log": false,
> "_ansible_parsed": true,
> "changed": true,
> "cmd": "openstack server list --all-projects --project
> \"ca257bcbf01745aba61edd9699cd4902\" | awk 'NR > 3 { print $2, $4 }' | grep
> -i \"TOMICS2\"",
> "delta": "0:00:02.312475",
> "end": "2019-09-24 09:15:48.113526",
> "failed": false,
> "invocation": {
> "module_args": {
> "_raw_params": "openstack server list
> --all-projects --project \"ca257bcbf01745aba61edd9699cd4902\" | awk 'NR > 3
> { print $2, $4 }' | grep -i \"TOMICS2\"",
> "_uses_shell": true,
> "argv": null,
> "chdir": null,
> "creates": null,
> "executable": null,
> "removes": null,
> "stdin": null,
> "warn": true
> }
> },
> "item": "TOMICS2",
> "rc": 0,
> "start": "2019-09-24 09:15:45.801051",
> "stderr": "",
> "stderr_lines": [],
> "stdout": "e8ebc5a4-17f3-4b80-a935-03164211a804
> TOMICS2",
>   *  "stdout_lines": [*
> *"e8ebc5a4-17f3-4b80-a935-03164211a804 TOMICS2"*
> ]
> },
>
>
>
> On Tuesday, September 24, 2019 at 10:55:00 PM UTC+5:30, Karl Auer wrote:
>>
>> What is the *complete* output from a debug of instid?
>>
>>
>> Regards, K.
>>
>>
>> On Wed, Sep 25, 2019 at 3:06 AM Rakesh Parida 
>> wrote:
>>
>>> Hi,
>>>
>>> I have  playbook to retrieve the Instance id of Openstack nodes.Now
>>> everything works fine but the resgitered value for instid.stdout_lines gets
>>> an undefined error.
>>> *The error was: 'dict object' has no attribute 'stdout_lines'* .. but
>>> when i debug the complete registered variable instid i see stdout_lines.
>>> but why its failing when i debug it using instid.stdout_lines
>>>
>>>  "item": "TOMCS2",
>>> "rc": 0,
>>> "start": "2019-09-24 09:15:45.801051",
>>> "stderr": "",
>>> "stderr_lines": [],
>>> "stdout": "e8ebc5a4-17f3-4b80-a935-03164211a804
>>> TOMICS2",
>>> *"stdout_lines": [*
>>> *"e8ebc5a4-17f3-4b80-a935-03164211a804 TOMCS2"*
>>>
>>>
>>> - hosts: nodes[0]
>>>   gather_facts: false
>>>   tasks:
>>> - name: Collect  Hostnames
>>>   set_fact:
>>>  host_lists: "{{ hostvars[inventory_hostname]['groups']['nodes']
>>> }}"
>>>
>>> - name: Create Hostname as per the Name in openstack names
>>>   set_fact:
>>>  fact: '{{ (["TOM"] *
>>> host_lists|length)|zip(host_lists)|map("join")|list}}'
>>>
>>> - name: Debug the required list
>>>   debug:
>>> m

Re: [ansible-project] Getting error for ".stdout_lines" for a registered variable

2019-09-24 Thread Karl Auer
What is the *complete* output from a debug of instid?


Regards, K.


On Wed, Sep 25, 2019 at 3:06 AM Rakesh Parida 
wrote:

> Hi,
>
> I have  playbook to retrieve the Instance id of Openstack nodes.Now
> everything works fine but the resgitered value for instid.stdout_lines gets
> an undefined error.
> *The error was: 'dict object' has no attribute 'stdout_lines'* .. but
> when i debug the complete registered variable instid i see stdout_lines.
> but why its failing when i debug it using instid.stdout_lines
>
>  "item": "TOMCS2",
> "rc": 0,
> "start": "2019-09-24 09:15:45.801051",
> "stderr": "",
> "stderr_lines": [],
> "stdout": "e8ebc5a4-17f3-4b80-a935-03164211a804
> TOMICS2",
> *"stdout_lines": [*
> *"e8ebc5a4-17f3-4b80-a935-03164211a804 TOMCS2"*
>
>
> - hosts: nodes[0]
>   gather_facts: false
>   tasks:
> - name: Collect  Hostnames
>   set_fact:
>  host_lists: "{{ hostvars[inventory_hostname]['groups']['nodes']
> }}"
>
> - name: Create Hostname as per the Name in openstack names
>   set_fact:
>  fact: '{{ (["TOM"] *
> host_lists|length)|zip(host_lists)|map("join")|list}}'
>
> - name: Debug the required list
>   debug:
> msg: "{{ fact }}"
>
>
> - hosts: 127.0.0.1
>   gather_facts: false
>   tasks:
> - name: Retrieve tenantID
>   shell: openstack project list | awk '/ TOM / { print $2 }'
>   register: tenantid
>
>  - name: Retrieve instance id from tenant
>shell: openstack server list --all-projects --project "{{
> tenantid.stdout }}" | awk 'NR > 3 { print $2, $4 }' | grep -i "{{ item }}"
>with_items: "{{ hostvars[groups['nodes'][0]]['fact'] }}"
>register: instid
>
> - name: Debug Instance id and Tennat id
>   delegate_to: localhost
>   debug:
> msg:
>  - "Tenant ID:"
>  - "{{ tenantid.stdout }}"
>  - "==="
>  - "Instance ID of the VMs in TOM
>  - "{{ instid.stdout_lines}}"
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/cc57f323-5d44-4b9b-97e9-ccc1e9f19542%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/cc57f323-5d44-4b9b-97e9-ccc1e9f19542%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 
Karl Auer

Email  : ka...@2pisoftware.com
Website: http://2pisoftware.com

GPG/PGP : 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E
Previous: 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08QYC5y4gQJ5OtthTRVZaS5TmRU7qxtoCjrJRNq3w8Y%2Bew%40mail.gmail.com.


Re: [ansible-project] Problem with "when" statement

2019-09-13 Thread Karl Auer
What does "no longer works" mean? What did you expect, what did you get?

The warning is correct - you should not use the braces in a when statement.

I'm not sure, but it sounds a bit as if the things you are comparing do not
contain the values you think they do

Regards, K.


On Fri, Sep 13, 2019 at 7:42 PM MKPhil  wrote:

>
> I'm trying to compare two variables in a "when" statement - when x = y do
> something.
>
> This code works:
>
> when: unit_number == {{ disk_unit }}
>
>
> BUT I get a warning:
>
>  [WARNING]: conditional statements should not include jinja2 templating
> delimiters such as {{ }} or {% %}. Found: unit_number == {{ disk_unit }}
>
>
> If I remove the {{ }} the statement no longer works.  How should I write
> the statement so it works and doesn't give the warning?  I've tried various
> combinations of double and single quotes and round brackets.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/92770bd7-d206-4a8c-83a8-0c949313557d%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/92770bd7-d206-4a8c-83a8-0c949313557d%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 
Karl Auer

Email  : ka...@2pisoftware.com
Website: http://2pisoftware.com

GPG/PGP : 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E
Previous: 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08SLta3_FxEvij3qd%3D3Piy-Fs54OPOUCD9_0AG3DbFNnyQ%40mail.gmail.com.


Re: [ansible-project] Update string variable if the value matches in Ansible Play

2019-09-12 Thread Karl Auer
My script uses inline variables, your script is passing in variables on the
command line.

It isn't obvious, but the fRegion you are setting is actually a different
variable to the one you are using later! To see this in action, try this
script using the command line "ansible-playbook -v scriptname -e
envvar=fred":

---
- hosts: localhost
  gather_facts: no

  vars:
 inlinevar: fred
 envvar: mary

  tasks
   - debug:
   var: envvar

   - set_fact:
   inlinevar: Boo

   - debug:
   var: inlinevar

   - set_fact:
   envvar: Boo

   - debug:
   var: envvar

set_fact creates a new host-level variable called envvar. debug uses the
highest-precedence envvar it can find, and extra vars (command line
variables) have the highest precedence of all.

To make your script work, set new inline variables to the values of  your
commandline variables, then use the inline variables.

Regards, K.
On Thu, Sep 12, 2019 at 9:11 PM Mohtashim S  wrote:

> @Karl, the user passes fRegion=prd_and_dr as evident from my previous post.
>
> ansible-playbook -vv finalattempt.yml -e "My_Number=54321 Layer=APP
> Environment=UAT fRegion=prd_and_dr"
>
>
> In my playbook the below condition should be met (true)
>
> when: fRegion == 'prd_and_dr' or fRegion == 'dr_and_prd'
>
> Thus, the fRegion variable should now get the value below instead of the
> one passed to the playbook.
>
> fRegion: "'prd_only' OR region LIKE 'dr_only'"
>
> However, in the output you can see '{{ fRegion }}'  the persists dr_and_prd
> value marked in *BOLD RED* in my previous post instead of printing
> (substituting) the new value i.e. 'prd_only' OR region LIKE 'dr_only'
>
> *Can you let me know how fRegion variable can be overwritten once the when
> condition is met ?*
>
>
> On Thursday, September 12, 2019 at 3:32:56 PM UTC+5:30, Karl Auer wrote:
>>
>> I'm sorry, I just don't know what's wrong with that. Please provide the
>> exact SQL statement you WANT to see, so we can compare it with the SQL
>> statement you are actually getting.
>>
>> I can't help feeling it would be simpler to provide just two booleans
>> "dr" and "prod" and pass in one or both, rather than comparing strings.
>>
>> Regards, K.
>>
>>
>> On Thu, Sep 12, 2019 at 7:38 PM Mohtashim S  wrote:
>>
>>> @Karl I tried set_fact as suggested but the assigned value is not
>>> getting substituted to the variable fRegion. Please look at the red bold
>>> text in the output below.
>>>
>>> Below is the playbook:
>>>
>>> cat finalattempt.yml
>>>
>>> ---
>>> - name: "Play 1"
>>>
>>>
>>>   hosts: localhost
>>>   gather_facts: no
>>>   tasks:
>>>- name: Setting SQL favourable string for fRegion incase prd_and_dr
>>> or dr_and_prd is passed as Region.
>>>  set_fact:
>>>fRegion: "'prd_only' OR region LIKE 'dr_only'"
>>>  when: fRegion == 'prd_and_dr' or fRegion == 'dr_and_prd'
>>>
>>>
>>>- name: "Search in  DB"
>>>  command: >
>>>mysql --user=root --password=p@ssword deployment
>>>--host=localhost --batch --skip-column-names
>>>--execute="SELECT my_num FROM mytable WHERE cr_num LIKE '{{
>>> My_Number }}' AND layer LIKE '{{ Layer }}' AND environment LIKE '{{
>>> Environment }}' AND (region LIKE '{{ fRegion }}' OR region LIKE
>>> 'prd_and_dr' OR region LIKE 'dr_and_prd')"
>>>
>>>
>>> Output:
>>>
>>> ansible-playbook -vv finalattempt.yml -e "My_Number=54321 Layer=APP
>>>> Environment=UAT fRegion=prd_and_dr"
>>>> ansible-playbook 2.8.1
>>>>   python version = 2.7.5 (default, Mar 26 2019, 22:13:06) [GCC 4.8.5
>>>> 20150623 (Red Hat 4.8.5-36)]
>>>> PLAYBOOK: finalattempt.yml
>>>> **
>>>> 1 plays in finalattempt.yml
>>>> PLAY [Play 1]
>>>> ***
>>>> META: ran handlers
>>>> TASK [Setting SQL favourable string for fRegion incase prd_and_dr or
>>>> dr_and_prd is passed as Region.]
>>>> ***

Re: [ansible-project] Update string variable if the value matches in Ansible Play

2019-09-12 Thread Karl Auer
I'm sorry, I just don't know what's wrong with that. Please provide the
exact SQL statement you WANT to see, so we can compare it with the SQL
statement you are actually getting.

I can't help feeling it would be simpler to provide just two booleans "dr"
and "prod" and pass in one or both, rather than comparing strings.

Regards, K.


On Thu, Sep 12, 2019 at 7:38 PM Mohtashim S  wrote:

> @Karl I tried set_fact as suggested but the assigned value is not getting
> substituted to the variable fRegion. Please look at the red bold text in
> the output below.
>
> Below is the playbook:
>
> cat finalattempt.yml
>
> ---
> - name: "Play 1"
>
>
>   hosts: localhost
>   gather_facts: no
>   tasks:
>- name: Setting SQL favourable string for fRegion incase prd_and_dr or
> dr_and_prd is passed as Region.
>  set_fact:
>fRegion: "'prd_only' OR region LIKE 'dr_only'"
>  when: fRegion == 'prd_and_dr' or fRegion == 'dr_and_prd'
>
>
>- name: "Search in  DB"
>  command: >
>mysql --user=root --password=p@ssword deployment
>--host=localhost --batch --skip-column-names
>--execute="SELECT my_num FROM mytable WHERE cr_num LIKE '{{
> My_Number }}' AND layer LIKE '{{ Layer }}' AND environment LIKE '{{
> Environment }}' AND (region LIKE '{{ fRegion }}' OR region LIKE
> 'prd_and_dr' OR region LIKE 'dr_and_prd')"
>
>
> Output:
>
> ansible-playbook -vv finalattempt.yml -e "My_Number=54321 Layer=APP
>> Environment=UAT fRegion=prd_and_dr"
>> ansible-playbook 2.8.1
>>   python version = 2.7.5 (default, Mar 26 2019, 22:13:06) [GCC 4.8.5
>> 20150623 (Red Hat 4.8.5-36)]
>> PLAYBOOK: finalattempt.yml
>> **
>> 1 plays in finalattempt.yml
>> PLAY [Play 1]
>> ***
>> META: ran handlers
>> TASK [Setting SQL favourable string for fRegion incase prd_and_dr or
>> dr_and_prd is passed as Region.]
>> *
>> task path: /app/Ansible/playbook/deployment/finalattempt.yml:8
>> ok: [localhost] => {"ansible_facts": {"fRegion": "'prd_only' OR region
>> LIKE 'dr_only'"}, "changed": false}
>> TASK [Search in  DB]
>> 
>> task path: /app/Ansible/playbook/deployment/finalattempt.yml:13
>> changed: [localhost] => {"changed": true, "cmd": ["mysql", "--user=root",
>> "--password=p@ssword", "deployment", "--host=localhost", "--batch",
>> "--skip-column-names", "--execute=SELECT my_num FROM mytable WHERE cr_num
>> LIKE '54321' AND layer LIKE 'APP' AND environment LIKE 'UAT' AND (region
>> LIKE *'prd_and_dr'* OR region LIKE 'prd_and_dr' OR region LIKE
>> 'dr_and_prd')"], "delta": "0:00:00.282201", "end": "2019-09-12
>> 14:58:18.054481", "rc": 0, "start": "2019-09-12 14:58:17.772280", "stderr":
>> "mysql: [Warning] Using a password on the command line interface can be
>> insecure.", "stderr_lines": ["mysql: [Warning] Using a password on the
>> command line interface can be insecure."], "stdout": "", "stdout_lines": []}
>> META: ran handlers
>> META: ran handlers
>> PLAY RECAP
>> **
>> localhost  : ok=2changed=1unreachable=0
>> failed=0skipped=0rescued=0ignored=0
>>
>
>
>
> On Thursday, September 12, 2019 at 10:45:58 AM UTC+5:30, Karl Auer wrote:
>>
>> That error is in code you added. I'm sure you'll figure it out.
>>
>> The fragments I supply here are tested unless I say otherwise.
>>
>> Regards, K.
>>
>> On Thu, Sep 12, 2019 at 2:59 PM Mohtashim S  wrote:
>>
>>> @Karl your set_fact recoomendation has syntax issues 
>>>
>>> Bel

Re: [ansible-project] Update string variable if the value matches in Ansible Play

2019-09-11 Thread Karl Auer
That error is in code you added. I'm sure you'll figure it out.

The fragments I supply here are tested unless I say otherwise.

Regards, K.

On Thu, Sep 12, 2019 at 2:59 PM Mohtashim S  wrote:

> @Karl your set_fact recoomendation has syntax issues 
>
> Below is how it fails.
>
> - name: "Play 1-Find the details here"
>
>
>   hosts: localhost
>   any_errors_fatal: True
>   vars:
> ansible_ssh_extra_args: -o StrictHostKeyChecking=no
>   set_fact:
> fRegion: "'prd' OR region LIKE 'dr'"
>   when: fRegion == 'prd_and_dr' or fRegion == 'dr_and_prd'
>
>
>   debug:
> msg: "{{ fRegion }}"
>
>
> Output:
>
>> ERROR! Syntax Error while loading YAML.
>>   did not find expected key
>> The error appears to be in '/app/changevar.yml': line 6, column 53, but
>> may
>> be elsewhere in the file depending on the exact syntax problem.
>> The offending line appears to be:
>> ansible_ssh_extra_args: -o StrictHostKeyChecking=no
>>     ^ here
>> There appears to be both 'k=v' shorthand syntax and YAML in this task.
>> Only one syntax may be used.
>
>
> On Wednesday, September 11, 2019 at 11:01:34 PM UTC+5:30, Karl Auer wrote:
>>
>> In this case you could use a ternary filter:
>>
>> vars:
>>  f1: "'prd' OR region LIKE 'dr'"
>>  f2: "some_default"
>>  sqlFragment: "{{(fRegion == 'prd_or_dr' or fRegion ==
>> 'dr_or_prd')|ternary(f1, f2)}}"
>> You could also use membership in a list of values as your condition:
>>
>> vars:
>>  f1: "'prd' OR region LIKE 'dr'"
>>  f2: "some_default"
>>  vals: ['dr_or_prd', 'prd_or_dr']
>>  sqlFragment: "{{(fRegion in vals) |ternary(f1, f2)}}"
>> BTW I used the f1 and f2 variables because it's the easiest way (maybe
>> the only way) to get single quotes into a variable.
>> IMHO this is not a good solution. The set_facts solution is much easier
>> to understand (and you can combine it with the list of values idea to
>> simplify it).
>>
>> Regards, K.
>>
>> On Thu, Sep 12, 2019 at 2:33 AM Mohtashim S  wrote:
>>
>>> @Karl you have correctly understood my requirement.
>>>
>>> However, can you propose a solution with vars instead of using set_fact ?
>>>
>>> On Wednesday, September 11, 2019 at 9:58:58 PM UTC+5:30, Karl Auer wrote:
>>>>
>>>> If I understand correctly you have a variable called fRegion that
>>>> contains a value.
>>>>
>>>> You want to change that variable to contain the string "'prd' OR
>>>> region LIKE 'dr'" if the variable initially contains either the value
>>>> "prd_or_dr" or the value "dr_or_prd".
>>>>
>>>> - set_fact:
>>>>  fRegion: "'prd' OR region LIKE 'dr'"
>>>>   when: fRegion == 'prd_or_dr' or fRegion == 'dr_or_prod'
>>>>
>>>> The problem with doing this is that you have lost the original value of
>>>> fRegion now. And you are IMHO misusing the variable; a variable should in
>>>> general either be a control variable (one that controls program flow) or
>>>> data. Using the same variable to contain both control information and data
>>>> at different times is confusing and leads to error. This would be nicer:
>>>>
>>>> - set_fact:
>>>>  sqlFragment: "'some default value'"
>>>>
>>>> - set_fact:
>>>>  sqlFragment: "'prd' OR region LIKE 'dr'"
>>>>   when: fRegion == 'prd_or_dr' or fRegion == 'dr_or_prd'
>>>>
>>>> Then it is completely clear that you are testing fRegion to find out
>>>> what yor SQL fragment should be.
>>>>
>>>> Regards, K.
>>>>
>>>> On Thu, Sep 12, 2019 at 2:03 AM Mohtashim S  wrote:
>>>>
>>>>> @Dick hi,
>>>>>
>>>>> We can definitely use a different variable here
>>>>>
>>>>> fRegion: "'prd' OR region LIKE 'dr'"
>>>>>
>>>>> I wanted to have less variables hence kept it the same.
>>>>>
>>>>

Re: [ansible-project] Update string variable if the value matches in Ansible Play

2019-09-11 Thread Karl Auer
In this case you could use a ternary filter:

vars:
 f1: "'prd' OR region LIKE 'dr'"
 f2: "some_default"
 sqlFragment: "{{(fRegion == 'prd_or_dr' or fRegion ==
'dr_or_prd')|ternary(f1, f2)}}"
You could also use membership in a list of values as your condition:

vars:
 f1: "'prd' OR region LIKE 'dr'"
 f2: "some_default"
 vals: ['dr_or_prd', 'prd_or_dr']
 sqlFragment: "{{(fRegion in vals) |ternary(f1, f2)}}"
BTW I used the f1 and f2 variables because it's the easiest way (maybe the
only way) to get single quotes into a variable.
IMHO this is not a good solution. The set_facts solution is much easier to
understand (and you can combine it with the list of values idea to simplify
it).

Regards, K.

On Thu, Sep 12, 2019 at 2:33 AM Mohtashim S  wrote:

> @Karl you have correctly understood my requirement.
>
> However, can you propose a solution with vars instead of using set_fact ?
>
> On Wednesday, September 11, 2019 at 9:58:58 PM UTC+5:30, Karl Auer wrote:
>>
>> If I understand correctly you have a variable called fRegion that
>> contains a value.
>>
>> You want to change that variable to contain the string "'prd' OR region
>> LIKE 'dr'" if the variable initially contains either the value
>> "prd_or_dr" or the value "dr_or_prd".
>>
>> - set_fact:
>>  fRegion: "'prd' OR region LIKE 'dr'"
>>   when: fRegion == 'prd_or_dr' or fRegion == 'dr_or_prod'
>>
>> The problem with doing this is that you have lost the original value of
>> fRegion now. And you are IMHO misusing the variable; a variable should in
>> general either be a control variable (one that controls program flow) or
>> data. Using the same variable to contain both control information and data
>> at different times is confusing and leads to error. This would be nicer:
>>
>> - set_fact:
>>  sqlFragment: "'some default value'"
>>
>> - set_fact:
>>  sqlFragment: "'prd' OR region LIKE 'dr'"
>>   when: fRegion == 'prd_or_dr' or fRegion == 'dr_or_prd'
>>
>> Then it is completely clear that you are testing fRegion to find out what
>> yor SQL fragment should be.
>>
>> Regards, K.
>>
>> On Thu, Sep 12, 2019 at 2:03 AM Mohtashim S  wrote:
>>
>>> @Dick hi,
>>>
>>> We can definitely use a different variable here
>>>
>>> fRegion: "'prd' OR region LIKE 'dr'"
>>>
>>> I wanted to have less variables hence kept it the same.
>>>
>>> The variable is used in a complex SQL query that is run by my playbook
>>> and as we know SQL queries need single quotes (')
>>>
>>> Thus, the fRegion variable or any other should be assigned the string
>>> which will embed in the SQL query to get it to work.
>>>
>>> On Wednesday, September 11, 2019 at 9:16:14 PM UTC+5:30, Dick Visser
>>> wrote:
>>>>
>>>> I am truly confused about the logic.
>>>> You’re trying to set a variable based on itself, OR itself?
>>>>
>>>> Could you maybe explain what you are trying to achieve?
>>>>
>>>> Even within this information I would definitely restructure things...
>>>>
>>>>
>>>> Dick
>>>>
>>>>
>>>>
>>>> On Wed, 11 Sep 2019 at 13:02, Mohtashim S  wrote:
>>>>
>>>>> I pass a variable fRegion to my ansible playbook.
>>>>>
>>>>> I wish to set fRegion  to this string ->  'prd' OR region LIKE 'dr'
>>>>>
>>>>> if the passed value is either "prd_and_dr" or "dr_and_prd".
>>>>>
>>>>> I call the playbook like this :
>>>>>
>>>>> ansible-playbook  site.yml -e "fRegion=dr_and_prd"
>>>>>
>>>>> Here is my attempted playbook that does not help.
>>>>>
>>>>> - name: "Play 1-Find the details here"
>>>>>
>>>>>
>>>>>   hosts: localhost
>>>>>   any_errors_fatal: True
>>>>>   vars:
>>>>>
>>>>>
>>>>> fRegion: "'prd' OR region LIKE 'dr'"
>>>>> when: fRegion == "prd_and_dr" or fRegion == "dr_

Re: [ansible-project] Update string variable if the value matches in Ansible Play

2019-09-11 Thread Karl Auer
If I understand correctly you have a variable called fRegion that contains
a value.

You want to change that variable to contain the string "'prd' OR region
LIKE 'dr'" if the variable initially contains either the value "prd_or_dr"
or the value "dr_or_prd".

- set_fact:
 fRegion: "'prd' OR region LIKE 'dr'"
  when: fRegion == 'prd_or_dr' or fRegion == 'dr_or_prod'

The problem with doing this is that you have lost the original value of
fRegion now. And you are IMHO misusing the variable; a variable should in
general either be a control variable (one that controls program flow) or
data. Using the same variable to contain both control information and data
at different times is confusing and leads to error. This would be nicer:

- set_fact:
 sqlFragment: "'some default value'"

- set_fact:
 sqlFragment: "'prd' OR region LIKE 'dr'"
  when: fRegion == 'prd_or_dr' or fRegion == 'dr_or_prd'

Then it is completely clear that you are testing fRegion to find out what
yor SQL fragment should be.

Regards, K.

On Thu, Sep 12, 2019 at 2:03 AM Mohtashim S  wrote:

> @Dick hi,
>
> We can definitely use a different variable here
>
> fRegion: "'prd' OR region LIKE 'dr'"
>
> I wanted to have less variables hence kept it the same.
>
> The variable is used in a complex SQL query that is run by my playbook and
> as we know SQL queries need single quotes (')
>
> Thus, the fRegion variable or any other should be assigned the string
> which will embed in the SQL query to get it to work.
>
> On Wednesday, September 11, 2019 at 9:16:14 PM UTC+5:30, Dick Visser wrote:
>>
>> I am truly confused about the logic.
>> You’re trying to set a variable based on itself, OR itself?
>>
>> Could you maybe explain what you are trying to achieve?
>>
>> Even within this information I would definitely restructure things...
>>
>>
>> Dick
>>
>>
>>
>> On Wed, 11 Sep 2019 at 13:02, Mohtashim S  wrote:
>>
>>> I pass a variable fRegion to my ansible playbook.
>>>
>>> I wish to set fRegion  to this string ->  'prd' OR region LIKE 'dr'
>>>
>>> if the passed value is either "prd_and_dr" or "dr_and_prd".
>>>
>>> I call the playbook like this :
>>>
>>> ansible-playbook  site.yml -e "fRegion=dr_and_prd"
>>>
>>> Here is my attempted playbook that does not help.
>>>
>>> - name: "Play 1-Find the details here"
>>>
>>>
>>>   hosts: localhost
>>>   any_errors_fatal: True
>>>   vars:
>>>
>>>
>>> fRegion: "'prd' OR region LIKE 'dr'"
>>> when: fRegion == "prd_and_dr" or fRegion == "dr_and_prd"
>>> ansible_ssh_extra_args: -o StrictHostKeyChecking=no
>>>
>>>
>>> debug:
>>>   msg: "{{ fRegion }}"
>>>
>>>
>>> Can you please suggest ?
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Ansible Project" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to ansible...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/ansible-project/7c6887c0-0579-45b0-bba4-835461f2401a%40googlegroups.com
>>> <https://groups.google.com/d/msgid/ansible-project/7c6887c0-0579-45b0-bba4-835461f2401a%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> --
>> Sent from a mobile device - please excuse the brevity, spelling and
>> punctuation.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/6565d2f2-c129-4b0b-9046-34a695f86107%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/6565d2f2-c129-4b0b-9046-34a695f86107%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 
Karl Auer

Email  : ka...@2pisoftware.com
Website: http://2pisoftware.com

GPG/PGP : 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E
Previous: 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08R4BLDKwAKHK5MuDxz0sebCsLEmtwdRV-GfnRJqfjX8Vw%40mail.gmail.com.


Re: [ansible-project] Temporarily disable Ansible from running on a host for 1 hour

2019-09-03 Thread Karl Auer
Put a check at the top of every script for a particular file; if the file
is there, stop.

On Wed, Sep 4, 2019 at 9:56 AM Nima V  wrote:

> I have Ansible running regularly via Jenkins. There are times where I want
> to prevent a host from running ansible temporarily. What is the best way to
> temporarily disable Ansible so that it does not run when Jenkins runs it.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/78a86819-5ae3-405c-82e9-52f8c811c8b8%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/78a86819-5ae3-405c-82e9-52f8c811c8b8%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 
Karl Auer

Email  : ka...@2pisoftware.com
Website: http://2pisoftware.com

GPG/PGP : 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E
Previous: 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08RoKmX1hOaGiT5BjnpT%3D2ssBD6KhVDEsPmPt4jucLHMkg%40mail.gmail.com.


Re: [ansible-project] Ansible - create a list from variable

2019-09-03 Thread Karl Auer
http://www.mydailytutorials.com/how-to-split-strings-and-join-them-in-a%E2%80%8Bnsibl%E2%80%8Be/

If your IP addresses are separated only by commas, and the comma-delimited
strings contain only IP addresses, split() will do the job nicely. If there
are things other than IP addresses in the input string, or if (as in your
example string) you have empty strings, you will need to sanity-check the
output from split().

Regards, K.


On Wed, Sep 4, 2019 at 12:52 AM TheSmiths  wrote:

> Hi,
>
> I would like to create a list from parsing a variable that contains
> multiple ips separated by a comma.
>
> The variable:
>
> *ips_input: ",1.1.1.1/32,2.2.2.2/32,3.3.3.3/32
> <http://1.1.1.1/32,2.2.2.2/32,3.3.3.3/32>"*
>
> every item in the list should contain ip/mask.
>
> the expected result:
>
> *ips_input_parsed: [*
> *   {*
> *   single_ip: "1.1.1.1/32 <http://1.1.1.1/32>"*
> *   }.*
> *   {*
> *   single_ip: "2.2.2.2/32 <http://2.2.2.2/32>"*
> *   }.*
> *   {*
> *   single_ip: "3.3.3.3/32 <http://3.3.3.3/32>"*
> *   }.*
> *]*
>
> tried many different ways including regex_replace with no success.
>
> please advise.
>
> Thanks,
> Morrissey
>
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/290b5352-d845-4cd1-9724-46d89907d51d%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/290b5352-d845-4cd1-9724-46d89907d51d%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 
Karl Auer

Email  : ka...@2pisoftware.com
Website: http://2pisoftware.com

GPG/PGP : 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E
Previous: 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08TYUoCANb0DFwks1TaQOyx%2B9wq4boC0%2B%3DhVkHnS6hQ3yA%40mail.gmail.com.


Re: [ansible-project] Re: Thoughts on Dynamic Variables

2019-09-03 Thread Karl Auer
You could use set_fact: stanzas instead, with when: clauses.

- set_fact:
user_list: 'user1, user2, user3'
  when: server_type = 'db_server'

Even better, use lists rather than strings. You can always turn one into
the other, and lists are more flexible:

- set_fact:
user_list: ['user1', 'user2', 'user3']
  when: server_type = 'db_server'
Or something like this:
vars:
   db_users: ['user1', 'user2', 'user3']
   web_users: ['user4', 'user5', 'user6']
   standard_users: 'user7', 'user8', 'user9']

- set_fact:
user_list: "{{ db_users }}"
when: server_type = 'db_server'
Or this:
vars:
   user_groups:
  {
 'db_server': ['user1', 'user2', 'user3'],
 'web_server': ['user4', 'user5', 'user6'],
 'standard_server': ['user7', 'user8', 'user9']
  }

- set_fact:
user_list: "{{ user_groups[ server_type ] }}"

The syntax is off the top of my head so probably full of errors, but it
should give you some ideas.

Regards, K.

On Tue, Sep 3, 2019 at 11:28 PM Cade Lambert  wrote:

> The problem I come across is I'll need logic to decide on the content of a
> variable and that logic will turn into a long string.  For example, when
> determining which users to add to a system, we might have a variable like:
>
> user_list: "{{ 'user1,user2,user3' if server_type=db_server else
> 'user4,user5,user6' if server_type=web_server else 'user7,user8,user1' if
> server_type=standard_server }}'
>
> These can get pretty long depending on what we're trying to do, and fairly
> hard to read. I could do multi-line variables I guess, but was wondering if
> there's a more clever way to handle stuff like this.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/38a5d109-d789-465b-9694-470c0b6b59d7%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/38a5d109-d789-465b-9694-470c0b6b59d7%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 
Karl Auer

Email  : ka...@2pisoftware.com
Website: http://2pisoftware.com

GPG/PGP : 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E
Previous: 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08Tn1fbfSx1g3BkQ7R3g1p3RjAZZm2v8-X%3DnsAX90-CVQA%40mail.gmail.com.


Re: [ansible-project] Why is this telling me the variable is undefined?

2019-08-26 Thread Karl Auer
path: is not indented?

On Mon, Aug 26, 2019 at 10:34 PM Chrono 7  wrote:

> I get an error stating:
>
> ERROR! no action detected in task. This often indicates a misspelled
> module name, or incorrect module path.
>
> The error appears to have been in 'system_info.yaml': line 7, column 7,
> but may
> be elsewhere in the file depending on the exact syntax problem.
>
> The offending line appears to be:
>
>   tasks:
> - name: Read the CSV & Set Values
>   ^ here
>
> That's with my file being reworked to:
>
> ---
>
> - name: Import CSV Containing Info For System(s) To Prep
>   hosts: 127.0.0.1
>
>   tasks:
>- name: Read the CSV & Set Values
>  read_csv:
>  path: systems.csv
>  register: systems
>  delegate_to: localhost
>
>- set_fact:
>IP: "{{ systems.list.1.IPAddress }}"
>
> I'm just trying to store values from a CSV file to a variable, I haven't
> had any luck so far unfortunately.
>
>
> ---
>
> - name: Import CSV Containing Info For System(s) To Prep
> hosts: 127.0.0.1
>
> tasks:
> - name: Read the CSV & Set Values
> read_csv:
> path: systems.csv
> register: systems
> delegate_to: localhost
>
> - set_fact:
> IP: "{{ systems.list.1.IPAddress }}"
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/bc158058-cd37-45f2-86df-a0aff57d356b%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/bc158058-cd37-45f2-86df-a0aff57d356b%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 
Karl Auer

Email  : ka...@2pisoftware.com
Website: http://2pisoftware.com

GPG/PGP : 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E
Previous: 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08T4KhrrCQUhqJGQq0kzBxamKq%2BPbBRTQBtBFW57DWancw%40mail.gmail.com.


Re: [ansible-project] Need a help to create S3 bucket using Ansible

2019-08-25 Thread Karl Auer
Get the AWS CLI working first. Can't help much there - perhaps it is a path
issue?

Regards, K.

On Mon, Aug 26, 2019 at 12:50 AM Amit Kulkarni 
wrote:

> Hi
>
> I have gone through the reply.
>
> I am using export commands already but despite that I am facing headbucket
> issue and error code is 403
> I have also installed AWS cli however it's still not recognizing aws
> command and I am getting aws command not found error when I am running any
> aws commands
> Let me know if any suggestions from your end
>
> Regards
> Amit
>
>
> On Sat, Aug 24, 2019, 10:42 PM Amit Kulkarni 
> wrote:
>
>> Thank you so much.
>> I will try it and give you feedback
>> Have a good night
>> Regards
>> Amit
>>
>> On Sat, Aug 24, 2019, 10:37 PM Karl Auer  wrote:
>>
>>> So I understand that these things are true:
>>>
>>> 1: You are logged into localhost as "root"
>>> 2: You are running Ansible as local user "root"
>>> 3: There is an IAM user called "ansible"
>>> 4: IAM user "ansible" has the necessary permissions
>>>
>>> You have set up a suitable user in AWS ("ansible"). now you have to make
>>> sure that the local user running Ansible (in your case "root") has access
>>> to the credentials locally, so that it can supply them to AWS as needed.
>>>
>>> There is no need to create any new IAM users.
>>>
>>> Typically you would (as the user running Ansible on your local host, so
>>> in your case as "root") run "aws configure" and then ensure that the
>>> right credentials are in ~root/.aws/config and ~root/.aws/credentials.
>>>
>>> You do not HAVE to install the AWS CLI to use Ansible. One alternative
>>> is to set all the required environment variables in your shell before
>>> running Ansible. At a minimum you need these:
>>>
>>> export AWS_ACCESS_KEY_ID=xx
>>> export AWS_SECRET_ACCESS_KEY=
>>>
>>> Many things expect AWS_REGION as well.
>>>
>>> All this is extensively documented in the Ansible documentation.
>>> There is little point trying to run Ansible until you have tested that
>>> the user you are running Ansible as (in your case root) can provide the
>>> required AWS access credentials. For this reason I suggest installing the
>>> AWS CLI   sure that you can do simple things like create and list buckets.
>>>
>>> Regards, K.
>>> On Sun, Aug 25, 2019 at 11:52 AM Amit Kulkarni 
>>> wrote:
>>>
>>>> Thanks Karl.
>>>> I having this confusion.
>>>>
>>>> I am logging in by root user however IAM user is ansible and I am using
>>>> it's credentials for export.
>>>>
>>>> How to rectify this?
>>>>
>>>> Do you suggest to create root as user in IAM to avoid the confusion
>>>>
>>>> Regards
>>>> Amit
>>>>
>>>> On Sat, Aug 24, 2019, 9:30 PM Karl Auer  wrote:
>>>>
>>>>> If you are getting a 403 error, then either you don't have the
>>>>> permissions you think you do, or you are not accessing AWS as the user you
>>>>> think you are.
>>>>>
>>>>> Carry out the desired operation using the command line while logged in
>>>>> (to localhost) as the user you think Ansible is using. If that works, then
>>>>> you 100% are using a different user in Ansible. If it doesn't work, then
>>>>> you don't have the permissions you think you do.
>>>>>
>>>>> For example, while logged in locally as "ansible":
>>>>>
>>>>> aws s3 mb s3://this_is_amits_bucket
>>>>> aws s3api head-bucket --bucket this_is_amits_bucket
>>>>>
>>>>> If the bucket already exists, just use the second command.
>>>>>
>>>>> Depending on how you have set up your AWS credentials, you may need to
>>>>> add "--profile whatever" to the commands, and possibly also "--region
>>>>> whatever".
>>>>>
>>>>> One other possibility is that the credentials the "ansible" user is
>>>>> using are set up with MFA in AWS. If that's the case, the above commands
>>>>> will prompt you for an MFA code.
>>>>>
>>>>> Regards, K.
>>>>>
>>>>&g

Re: [ansible-project] Need a help to create S3 bucket using Ansible

2019-08-24 Thread Karl Auer
So I understand that these things are true:

1: You are logged into localhost as "root"
2: You are running Ansible as local user "root"
3: There is an IAM user called "ansible"
4: IAM user "ansible" has the necessary permissions

You have set up a suitable user in AWS ("ansible"). now you have to make
sure that the local user running Ansible (in your case "root") has access
to the credentials locally, so that it can supply them to AWS as needed.

There is no need to create any new IAM users.

Typically you would (as the user running Ansible on your local host, so in
your case as "root") run "aws configure" and then ensure that the right
credentials are in ~root/.aws/config and ~root/.aws/credentials.

You do not HAVE to install the AWS CLI to use Ansible. One alternative is
to set all the required environment variables in your shell before running
Ansible. At a minimum you need these:

export AWS_ACCESS_KEY_ID=xx
export AWS_SECRET_ACCESS_KEY=

Many things expect AWS_REGION as well.

All this is extensively documented in the Ansible documentation.
There is little point trying to run Ansible until you have tested that the
user you are running Ansible as (in your case root) can provide the
required AWS access credentials. For this reason I suggest installing the
AWS CLI   sure that you can do simple things like create and list buckets.

Regards, K.
On Sun, Aug 25, 2019 at 11:52 AM Amit Kulkarni 
wrote:

> Thanks Karl.
> I having this confusion.
>
> I am logging in by root user however IAM user is ansible and I am using
> it's credentials for export.
>
> How to rectify this?
>
> Do you suggest to create root as user in IAM to avoid the confusion
>
> Regards
> Amit
>
> On Sat, Aug 24, 2019, 9:30 PM Karl Auer  wrote:
>
>> If you are getting a 403 error, then either you don't have the
>> permissions you think you do, or you are not accessing AWS as the user you
>> think you are.
>>
>> Carry out the desired operation using the command line while logged in
>> (to localhost) as the user you think Ansible is using. If that works, then
>> you 100% are using a different user in Ansible. If it doesn't work, then
>> you don't have the permissions you think you do.
>>
>> For example, while logged in locally as "ansible":
>>
>> aws s3 mb s3://this_is_amits_bucket
>> aws s3api head-bucket --bucket this_is_amits_bucket
>>
>> If the bucket already exists, just use the second command.
>>
>> Depending on how you have set up your AWS credentials, you may need to
>> add "--profile whatever" to the commands, and possibly also "--region
>> whatever".
>>
>> One other possibility is that the credentials the "ansible" user is using
>> are set up with MFA in AWS. If that's the case, the above commands will
>> prompt you for an MFA code.
>>
>> Regards, K.
>>
>>
>> On Sun, Aug 25, 2019 at 11:02 AM Amit Kulkarni 
>> wrote:
>>
>>> IAM user has full permission on S3.
>>>
>>> Let me know what additional information needed.
>>>
>>> Regards
>>> Amit
>>>
>>> On Sat, Aug 24, 2019 at 8:57 PM Karl Auer  wrote:
>>>
>>>> More info needed. Check the credentials you are using and the
>>>> permissions they provide.
>>>>
>>>> Regards, K.
>>>>
>>>>
>>>> On Sun, Aug 25, 2019 at 10:42 AM Amit Kulkarni 
>>>> wrote:
>>>>
>>>>> I was able to over the credentials issue
>>>>> But  getting 403 error as head bucket forbidden issue.
>>>>>
>>>>> Regards
>>>>> Amit
>>>>>
>>>>> On Sat, Aug 24, 2019, 8:38 PM Karl Auer  wrote:
>>>>>
>>>>>> I haven't had a close look, but I think the problem is that while you
>>>>>> are logged in as ansible, your playbook thn connects to localhost as 
>>>>>> root.
>>>>>> and root does not have AWS credentials set up. From your output:
>>>>>>
>>>>>> [...]
>>>>>> ESTABLISH LOCAL CONNECTION FOR USER: root
>>>>>> [...]
>>>>>> NoCredentialsError: Unable to locate credentials
>>>>>> [...]
>>>>>>
>>>>>> In general, when running Ansible on a local host to change AWS
>>>>>> resources (rather than running a play on a remote host), you don't need 
>>>>>> to
>>>>>> 

Re: [ansible-project] Need a help to create S3 bucket using Ansible

2019-08-24 Thread Karl Auer
If you are getting a 403 error, then either you don't have the permissions
you think you do, or you are not accessing AWS as the user you think you
are.

Carry out the desired operation using the command line while logged in (to
localhost) as the user you think Ansible is using. If that works, then you
100% are using a different user in Ansible. If it doesn't work, then you
don't have the permissions you think you do.

For example, while logged in locally as "ansible":

aws s3 mb s3://this_is_amits_bucket
aws s3api head-bucket --bucket this_is_amits_bucket

If the bucket already exists, just use the second command.

Depending on how you have set up your AWS credentials, you may need to
add "--profile
whatever" to the commands, and possibly also "--region whatever".

One other possibility is that the credentials the "ansible" user is using
are set up with MFA in AWS. If that's the case, the above commands will
prompt you for an MFA code.

Regards, K.


On Sun, Aug 25, 2019 at 11:02 AM Amit Kulkarni 
wrote:

> IAM user has full permission on S3.
>
> Let me know what additional information needed.
>
> Regards
> Amit
>
> On Sat, Aug 24, 2019 at 8:57 PM Karl Auer  wrote:
>
>> More info needed. Check the credentials you are using and the permissions
>> they provide.
>>
>> Regards, K.
>>
>>
>> On Sun, Aug 25, 2019 at 10:42 AM Amit Kulkarni 
>> wrote:
>>
>>> I was able to over the credentials issue
>>> But  getting 403 error as head bucket forbidden issue.
>>>
>>> Regards
>>> Amit
>>>
>>> On Sat, Aug 24, 2019, 8:38 PM Karl Auer  wrote:
>>>
>>>> I haven't had a close look, but I think the problem is that while you
>>>> are logged in as ansible, your playbook thn connects to localhost as root.
>>>> and root does not have AWS credentials set up. From your output:
>>>>
>>>> [...]
>>>> ESTABLISH LOCAL CONNECTION FOR USER: root
>>>> [...]
>>>> NoCredentialsError: Unable to locate credentials
>>>> [...]
>>>>
>>>> In general, when running Ansible on a local host to change AWS
>>>> resources (rather than running a play on a remote host), you don't need to
>>>> become a different user. So try just running the playbook on localhost as
>>>> user "ansible" (assuming that you have AWS credentials set up for "ansible"
>>>> of course.
>>>>
>>>> Alternatively, log in as root and set up AWS credentials in the root
>>>> account on localhost. Not really a recommended approach.
>>>>
>>>> For most of my playbooks that work with AWS infrastructure, I run them
>>>> as a user with suitable AWS credentials, and the playbooks start like this:
>>>>
>>>> ---
>>>> - hosts: localhost
>>>>   connection: local
>>>>   gather_facts: false
>>>>   become: false
>>>>
>>>> Regards, K.
>>>>
>>>>
>>>> On Sun, Aug 25, 2019 at 10:05 AM Amit Kulkarni 
>>>> wrote:
>>>>
>>>>> Hello All,
>>>>>
>>>>> I tried to change the bucket name and ran my playbook, but its failing
>>>>> with same error.
>>>>>
>>>>> I even specified the region as my EC2 instance but still its failing.
>>>>> Below are my boto versions
>>>>> boto3 (1.9.212)
>>>>> botocore (1.12.215)
>>>>>
>>>>> Please suggest if i am doing something wrong here. I have also
>>>>> attached s3 full access policy to my IAM user.
>>>>> I am running this playbook as root user and my IAM user name is
>>>>> ansible.
>>>>>
>>>>> root@ip-172-31-42-232:/etc/ansible# ansible-playbook s3.yml -vvv
>>>>> ansible-playbook 2.8.3
>>>>>   config file = /etc/ansible/ansible.cfg
>>>>>   configured module search path = [u'/root/.ansible/plugins/modules',
>>>>> u'/usr/share/ansible/plugins/modules']
>>>>>   ansible python module location =
>>>>> /usr/lib/python2.7/dist-packages/ansible
>>>>>   executable location = /usr/bin/ansible-playbook
>>>>>   python version = 2.7.12 (default, Nov 12 2018, 14:36:49) [GCC 5.4.0
>>>>> 20160609]
>>>>> Using /etc/ansible/ansible.cfg as config file
>>>>> host_list declined parsing /etc/ansible/hosts as it did not pass it's
>>

Re: [ansible-project] Need a help to create S3 bucket using Ansible

2019-08-24 Thread Karl Auer
More info needed. Check the credentials you are using and the permissions
they provide.

Regards, K.


On Sun, Aug 25, 2019 at 10:42 AM Amit Kulkarni 
wrote:

> I was able to over the credentials issue
> But  getting 403 error as head bucket forbidden issue.
>
> Regards
> Amit
>
> On Sat, Aug 24, 2019, 8:38 PM Karl Auer  wrote:
>
>> I haven't had a close look, but I think the problem is that while you are
>> logged in as ansible, your playbook thn connects to localhost as root. and
>> root does not have AWS credentials set up. From your output:
>>
>> [...]
>> ESTABLISH LOCAL CONNECTION FOR USER: root
>> [...]
>> NoCredentialsError: Unable to locate credentials
>> [...]
>>
>> In general, when running Ansible on a local host to change AWS resources
>> (rather than running a play on a remote host), you don't need to become a
>> different user. So try just running the playbook on localhost as user
>> "ansible" (assuming that you have AWS credentials set up for "ansible" of
>> course.
>>
>> Alternatively, log in as root and set up AWS credentials in the root
>> account on localhost. Not really a recommended approach.
>>
>> For most of my playbooks that work with AWS infrastructure, I run them as
>> a user with suitable AWS credentials, and the playbooks start like this:
>>
>> ---
>> - hosts: localhost
>>   connection: local
>>   gather_facts: false
>>   become: false
>>
>> Regards, K.
>>
>>
>> On Sun, Aug 25, 2019 at 10:05 AM Amit Kulkarni 
>> wrote:
>>
>>> Hello All,
>>>
>>> I tried to change the bucket name and ran my playbook, but its failing
>>> with same error.
>>>
>>> I even specified the region as my EC2 instance but still its failing.
>>> Below are my boto versions
>>> boto3 (1.9.212)
>>> botocore (1.12.215)
>>>
>>> Please suggest if i am doing something wrong here. I have also attached
>>> s3 full access policy to my IAM user.
>>> I am running this playbook as root user and my IAM user name is ansible.
>>>
>>> root@ip-172-31-42-232:/etc/ansible# ansible-playbook s3.yml -vvv
>>> ansible-playbook 2.8.3
>>>   config file = /etc/ansible/ansible.cfg
>>>   configured module search path = [u'/root/.ansible/plugins/modules',
>>> u'/usr/share/ansible/plugins/modules']
>>>   ansible python module location =
>>> /usr/lib/python2.7/dist-packages/ansible
>>>   executable location = /usr/bin/ansible-playbook
>>>   python version = 2.7.12 (default, Nov 12 2018, 14:36:49) [GCC 5.4.0
>>> 20160609]
>>> Using /etc/ansible/ansible.cfg as config file
>>> host_list declined parsing /etc/ansible/hosts as it did not pass it's
>>> verify_file() method
>>> script declined parsing /etc/ansible/hosts as it did not pass it's
>>> verify_file() method
>>> auto declined parsing /etc/ansible/hosts as it did not pass it's
>>> verify_file() method
>>> Parsed /etc/ansible/hosts inventory source with ini plugin
>>>
>>> PLAYBOOK: s3.yml
>>> ***
>>> 1 plays in s3.yml
>>>
>>> PLAY [localhost]
>>> ***
>>>
>>> TASK [Gathering Facts]
>>> *
>>> task path: /etc/ansible/s3.yml:2
>>> <127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: root
>>> <127.0.0.1> EXEC /bin/sh -c 'echo ~root && sleep 0'
>>> <127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo
>>> /root/.ansible/tmp/ansible-tmp-1566690636.74-275478344374659 `" && echo
>>> ansible-tmp-1566690636.74-275478344374659="` echo
>>> /root/.ansible/tmp/ansible-tmp-1566690636.74-275478344374659 `" ) && sleep
>>> 0'
>>> Using module file
>>> /usr/lib/python2.7/dist-packages/ansible/modules/system/setup.py
>>> <127.0.0.1> PUT /root/.ansible/tmp/ansible-local-3920YJ0Dzu/tmppvx33n TO
>>> /root/.ansible/tmp/ansible-tmp-1566690636.74-275478344374659/AnsiballZ_setup.py
>>> <127.0.0.1> EXEC /bin/s

Re: [ansible-project] Need a help to create S3 bucket using Ansible

2019-08-24 Thread Karl Auer
;>>> Using module file
>>>> /usr/lib/python2.7/dist-packages/ansible/modules/system/setup.py
>>>> <127.0.0.1> PUT
>>>> /home/ubuntu/.ansible/tmp/ansible-local-16195TKTGUm/tmpzD3QiP TO
>>>> /root/.ansible/tmp/ansible-tmp-1566352417.53-61320358842100/AnsiballZ_setup.py
>>>> <127.0.0.1> EXEC /bin/sh -c 'chmod u+x
>>>> /root/.ansible/tmp/ansible-tmp-1566352417.53-61320358842100/
>>>> /root/.ansible/tmp/ansible-tmp-1566352417.53-61320358842100/AnsiballZ_setup.py
>>>> && sleep 0'
>>>> <127.0.0.1> EXEC /bin/sh -c '/usr/bin/python
>>>> /root/.ansible/tmp/ansible-tmp-1566352417.53-61320358842100/AnsiballZ_setup.py
>>>> && sleep 0'
>>>> <127.0.0.1> EXEC /bin/sh -c 'rm -f -r
>>>> /root/.ansible/tmp/ansible-tmp-1566352417.53-61320358842100/ > /dev/null
>>>> 2>&1 && sleep 0'
>>>> ok: [localhost]
>>>> META: ran handlers
>>>> TASK [Create an empty bucket]
>>>> **
>>>> task path: /etc/ansible/s3.yml:4
>>>> <127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: root
>>>> <127.0.0.1> EXEC /bin/sh -c 'echo ~root && sleep 0'
>>>> <127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo
>>>> /root/.ansible/tmp/ansible-tmp-1566352418.34-246931485115878 `" && echo
>>>> ansible-tmp-1566352418.34-246931485115878="` echo
>>>> /root/.ansible/tmp/ansible-tmp-1566352418.34-246931485115878 `" ) && sleep
>>>> 0'
>>>> Using module file
>>>> /usr/lib/python2.7/dist-packages/ansible/modules/cloud/amazon/aws_s3.py
>>>> <127.0.0.1> PUT
>>>> /home/ubuntu/.ansible/tmp/ansible-local-16195TKTGUm/tmpleczvh TO
>>>> /root/.ansible/tmp/ansible-tmp-1566352418.34-246931485115878/AnsiballZ_aws_s3.py
>>>> <127.0.0.1> EXEC /bin/sh -c 'chmod u+x
>>>> /root/.ansible/tmp/ansible-tmp-1566352418.34-246931485115878/
>>>> /root/.ansible/tmp/ansible-tmp-1566352418.34-246931485115878/AnsiballZ_aws_s3.py
>>>> && sleep 0'
>>>> <127.0.0.1> EXEC /bin/sh -c '/usr/bin/python
>>>> /root/.ansible/tmp/ansible-tmp-1566352418.34-246931485115878/AnsiballZ_aws_s3.py
>>>> && sleep 0'
>>>> <127.0.0.1> EXEC /bin/sh -c 'rm -f -r
>>>> /root/.ansible/tmp/ansible-tmp-1566352418.34-246931485115878/ > /dev/null
>>>> 2>&1 && sleep 0'
>>>> The full traceback is:
>>>> Traceback (most recent call last):
>>>>   File "/tmp/ansible_aws_s3_payload_6bl3f1/__main__.py", line 384, in
>>>> bucket_check
>>>> s3.head_bucket(Bucket=bucket)
>>>>   File "/usr/local/lib/python2.7/dist-packages/botocore/client.py",
>>>> line 357, in _api_call
>>>> return self._make_api_call(operation_name, kwargs)
>>>>   File "/usr/local/lib/python2.7/dist-packages/botocore/client.py",
>>>> line 648, in _make_api_call
>>>> operation_model, request_dict, request_context)
>>>>   File "/usr/local/lib/python2.7/dist-packages/botocore/client.py",
>>>> line 667, in _make_request
>>>> return self._endpoint.make_request(operation_model, request_dict)
>>>>   File "/usr/local/lib/python2.7/dist-packages/botocore/endpoint.py",
>>>> line 102, in make_request
>>>> return self._send_request(request_dict, operation_model)
>>>>   File "/usr/local/lib/python2.7/dist-packages/botocore/endpoint.py",
>>>> line 132, in _send_request
>>>> request = self.create_request(request_dict, operation_model)
>>>>   File "/usr/local/lib/python2.7/dist-packages/botocore/endpoint.py",
>>>> line 116, in create_request
>>>> operation_name=operation_model.name)
>>>>   File "/usr/local/lib/python2.7/dist-packages/botocore/hooks.py", line
>>>> 356, in emit
>>>> return self._emitter.emit(aliased_event_name, **kwargs)
>>>>   File "/usr/local/lib/python2.7/dist-packages/botocore/hooks.py", line
>>>> 228, in emit
>>>> return self._emit(event_name, kwargs)
>>>>   File "/usr/local/lib/python2.7/dist-packages/botocore/hooks.py", line
>>>> 211, in _emit
>>>> response = handler(**kwargs)
>>>>   File "/usr/local/lib/python2.7/dist-packages/botocore/signers.py",
>>>> line 90, in handler
>>>> return self.sign(operation_name, request)
>>>>   File "/usr/local/lib/python2.7/dist-packages/botocore/signers.py",
>>>> line 157, in sign
>>>> auth.add_auth(request)
>>>>   File "/usr/local/lib/python2.7/dist-packages/botocore/auth.py", line
>>>> 425, in add_auth
>>>> super(S3SigV4Auth, self).add_auth(request)
>>>>   File "/usr/local/lib/python2.7/dist-packages/botocore/auth.py", line
>>>> 357, in add_auth
>>>> raise NoCredentialsError
>>>> NoCredentialsError: Unable to locate credentials
>>>> fatal: [localhost]: FAILED! => {
>>>> "boto3_version": "1.9.212",
>>>> "botocore_version": "1.12.212",
>>>> "changed": false,
>>>> "invocation": {
>>>> "module_args": {
>>>> "aws_access_key": "",
>>>> "aws_secret_key": "",
>>>> "bucket": "mybucket",
>>>> "debug_botocore_endpoint_logs": false,
>>>> "dest": null,
>>>> "dualstack": false,
>>>> "ec2_url": null,
>>>> "encrypt": true,
>>>> "encryption_kms_key_id": null,
>>>> "encryption_mode": "AES256",
>>>> "expiry": 600,
>>>> "headers": null,
>>>> "ignore_nonexistent_bucket": false,
>>>> "marker": "",
>>>> "max_keys": 1000,
>>>> "metadata": null,
>>>> "mode": "create",
>>>> "object": null,
>>>> "overwrite": "always",
>>>> "permission": [
>>>> "public-read"
>>>> ],
>>>> "prefix": "",
>>>> "profile": null,
>>>> "region": null,
>>>> "retries": 0,
>>>> "rgw": false,
>>>> "s3_url": null,
>>>> "security_token": null,
>>>> "src": null,
>>>> "validate_certs": true,
>>>> "version": null
>>>> }
>>>> },
>>>> "msg": "Failed while looking up bucket (during bucket_check)
>>>> mybucket.: Unable to locate credentials"
>>>> }
>>>> PLAY RECAP
>>>> *
>>>> localhost  : ok=1changed=0unreachable=0
>>>> failed=1skipped=0rescued=0ignored=0
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Ansible Project" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to ansible-project+unsubscr...@googlegroups.com.
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/ansible-project/6f4720f9-66bc-4af9-be2c-e677128488ba%40googlegroups.com
>>>> <https://groups.google.com/d/msgid/ansible-project/6f4720f9-66bc-4af9-be2c-e677128488ba%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Ansible Project" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to ansible-project+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/ansible-project/CAON3ZR3dB3KGH%2BK8F88_w9s2fUzFbwtYfmouN5t%2BwJMRUA%2BU7w%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/ansible-project/CAON3ZR3dB3KGH%2BK8F88_w9s2fUzFbwtYfmouN5t%2BwJMRUA%2BU7w%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Ansible Project" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to ansible-project+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/CAD0rZAxieHf_cBSfUHEyAftMTqxpxoD4wpy%3DThJTXf1qQqsccA%40mail.gmail.com
>> <https://groups.google.com/d/msgid/ansible-project/CAD0rZAxieHf_cBSfUHEyAftMTqxpxoD4wpy%3DThJTXf1qQqsccA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAON3ZR2Umumc3Vib3ynosNMa%3DpfSCSPkWwTR-QMB-O4mPXJXyQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CAON3ZR2Umumc3Vib3ynosNMa%3DpfSCSPkWwTR-QMB-O4mPXJXyQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>


-- 
Karl Auer

Email  : ka...@2pisoftware.com
Website: http://2pisoftware.com

GPG/PGP : 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E
Previous: 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08S%3DrxW7a_wZco50UcoV%3DkKM8b0anijjm-zTR_fMvjfeMA%40mail.gmail.com.


Re: [ansible-project] Re: execute one task of a playbook locally and the rest on the remote hosts?

2019-08-20 Thread Karl Auer
Haven't checked this, but I think you can have multiple sections in a
playbook with different hosts. Maybe not.

Try
- hosts: localhost
   ...

- hosts: something_else
   ...

I assume (always dangerous) that if it works at all the hosts sections
would be processed in order, so you could rely on the localhost stuff
happening first.

Regards, K.


On Wed, Aug 21, 2019 at 12:41 AM Mike Eggleston 
wrote:

> That's a great idea. Thank you.
>
> Mike
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/40b509a6-3f65-4060-8c2f-e06e59064163%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/40b509a6-3f65-4060-8c2f-e06e59064163%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 
Karl Auer

Email  : ka...@2pisoftware.com
Website: http://2pisoftware.com

GPG/PGP : 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E
Previous: 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08SwJRvKTjcgmgZV31%2Bryok4CqpPJnR0EZtzHvH1gnrUJA%40mail.gmail.com.


Re: [ansible-project] best way to wait for AWS metadata to resolve?

2019-08-18 Thread Karl Auer
There's a wait option on ec2 instance creation that will stop the playbook
until the instance is up. Not sure what exactly it is testing, but I've
seen it there.

A primitive alternative is just to stick a one-minute (or whatever is
needed) delay into the playbook.

You can also put a delay loop in. See this link and seach for "Retrying":

https://docs.ansible.com/ansible/latest/user_guide/playbooks_loops.html

Regards, K.


On Mon, Aug 19, 2019 at 10:52 AM Jim Robinson 
wrote:

> I'm not sure whether this is something ansible can do out of the box or
> not.
>
> I am looking for a way to pause execution of a playbook until certain
> pieces of metadata become available from AWS.
>
> Basically I'm starting an ec2 instance inside a firewalled VPC in AWS and
> when it's ready it sets a few tag values.
>
> I'd like to be able to construct tasks that spin up this ec2 instance,
> wait until it sees those tags are available (or times out), and then
> continue.
>
> Is this possible using the standard ansible toolkit, or am I (a) going
> about this all wrong, or (b) going to need to reach for a custom coded
> module?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/749822ac-0100-4bb8-83e5-f28ee777a1b3%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/749822ac-0100-4bb8-83e5-f28ee777a1b3%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 
Karl Auer

Email  : ka...@2pisoftware.com
Website: http://2pisoftware.com

GPG/PGP : 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E
Previous: 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08SCxt1yZf1K9jJgFxq-1Dpo46HVFN4a6emeUbYH3W81jg%40mail.gmail.com.


Re: [ansible-project] Help wanted: "Including" playbooks for a "Playbook of Playbooks"

2019-07-18 Thread Karl Auer
 programB] 
> fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "",
> "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the
> exact error", "rc": 0}
> ...ignoring
>
> From above, what might be the module failure being referred to?
>
> General layout/schema of *playbooks/program[A-Z].yml* (here, ... means
> the end of the YAML file):
> # playbooks/programA.yml
> ---
> - name: Run role of ProgramA for required hosts
>   hosts: hostA,hostC,groupB
>   gather_facts: no
>   strategy: free
>   roles:
> - programA
> ...
>
> # playbooks/programB.yml
> ---
> - name: Run role of ProgramY for required hosts
>   hosts: hostD,groupW
>   gather_facts: no
>   strategy: free
>   roles:
> - programB
> ...
>
> General layout/schema of *roles/program[A-Z]/tasks/main.yml* (here, ...
> means the end of the YAML file):
> ---
> - name: Role for ProgramA
>   include_role:
> name: other_role
>   vars:
> var1: something
> var2: somethingElse
> ...
>
> Thank you for taking your time to read this post.
> Any assistance would be appreciated.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/6776ba24-a467-40d3-ac90-90d1fae41539%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/6776ba24-a467-40d3-ac90-90d1fae41539%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 
Karl Auer

Email  : ka...@2pisoftware.com
Website: http://2pisoftware.com

GPG/PGP : 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E
Previous: 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08TO5crAnOs8rUAeDuCB_cxx%3DuQ3eHyExvZ-yejnH2a3vw%40mail.gmail.com.


Re: [ansible-project] ansible syntax to use "if-else" and "set"

2019-06-15 Thread Karl Auer
Or maybe a series of set_fact: statements:

- set_fact
 group: 'BAD'

- set_fact:
 group: grp1
  when: c == 1
- set_fact:
 group: grp2
  when: c == 2

- set_fact:
 group: grp3
  when: c == 3

[...etc...]

- fail:
 msg: "Invalid value for 'c' or 'c' not set!"
  when: group == 'BAD'

Regards, K.

On Mon, Jun 3, 2019 at 4:52 PM S C Rigler  wrote:

> In your example of what you're trying to do, you're setting "group" inside
> of the template but never returning it to the task.  What you might want is
> something like this:
>
> - name: Set Group
>   set_fact:
> group: |
>   {% if c == 1 %}
>   grp1
>   {% elif c ==2 %}
>   grp3
>   {% else %}
>   grp4
>   {% endif %}
>
> -- Steve
>
> On Mon, Jun 3, 2019 at 12:49 AM Ansar Sahit  wrote:
>
>> Hi All,
>>
>> Im trying to choose ansible inventory host group conditionally.
>>
>> - name: Set group
>>   set_fact:
>> group: |
>> {% if c == 1 %}
>> {% set group = 'grp1' %}
>> {% elif c == 2 %}
>> {% set group == 'grp3' %}
>> {% else %}
>> {% group == 'grp4' %}
>> {% endif %}
>>
>> - debug:
>>  var=group
>>
>>
>> This doesnt seem to work.
>>
>> Whats the right way to use if-else with ansible set??
>>
>> Kinldy assist.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Ansible Project" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to ansible-project+unsubscr...@googlegroups.com.
>> To post to this group, send email to ansible-project@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/de181027-dc27-4190-8d1e-1e5feec12546%40googlegroups.com
>> <https://groups.google.com/d/msgid/ansible-project/de181027-dc27-4190-8d1e-1e5feec12546%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAFbiokdBbOsnz5nVCMbX-9ouTTL4K8jL2WNoQKz-F-MBYZq0fg%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CAFbiokdBbOsnz5nVCMbX-9ouTTL4K8jL2WNoQKz-F-MBYZq0fg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Karl Auer

Email  : ka...@2pisoftware.com
Website: http://2pisoftware.com

GPG/PGP : 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E
Previous: 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08Tc%3Db5qVFEOA14dYp68cxcOZGoDS4eyR1wD%3DaVBQMX3SQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] playbook to start AWS instance, run some tasks on the AWS instance, then terminate the instance

2019-05-24 Thread Karl Auer
Or look into AWS Batch. It's also fantastic for parallelisable tasks or
many identical tasks. Lambda for tiny short-lived tasks, Batch for larger
or long-lived tasks. Takes a bit of setup, but well worth it.

Regards, K.


On Sat, May 25, 2019 at 4:10 PM Barun kumar  wrote:

> There will be way to do it, but let me tell you that ansible is mainly
> used for configuration and management not or orchestration, it has module
> limitations. If you want to do infrastructure orchestration and for AWS
> specially then I would request you to go for terraform for infrastructure
> provisioning, it has many feature and easy to use even you can call ansible
> playbooks to perform post build taks.
>
> https://www.terraform.io/intro/index.html
>
> Hope this will help you, I know u had asked for ansible and I am telling
> you to use terraform, once you use it, will love it. Try it.
>
> On Sat, 25 May 2019, 10:09 Tuyen Nguyen,  wrote:
>
>> Hi
>>
>> I thought variables cannot go across different plays in a playbook ?
>>
>> I know how to create a playbook to start up an AWS instance, and register
>> the instance_id of the new instance, and then use the ec2 module again to
>> terminate the instance_id.
>>
>> Initially to start up the AWS instance, I need to run the play with
>> hosts: localhost, and I register the instance_id as a variable in Ansible
>>
>> If I do
>> hosts: 
>> after that, and I can run the task against the client on the IP address,
>>
>> but then next, if I do hosts: localhost again to use the ec2 module to
>> terminate the instance, would I be able to call on the instance_id variable?
>>
>>
>> On Friday, May 24, 2019 at 2:16:09 PM UTC-4, Barun kumar wrote:
>>>
>>> You can call facts variable in playbook ,
>>> 1- playbook to create a instace
>>> 2- register instance instance creation facts and call IP to normal tasks
>>> adding variable in same play then call terminate playbook below.
>>>
>>> I have given you logic, more thought process you  need to apply while
>>> you create a playbook taks.
>>>
>>>
>>>
>>>
>>> On Fri, 24 May 2019, 23:02 Tuyen Nguyen,  wrote:
>>>
>>>> Hi
>>>>
>>>> Currently, to do what I want to do above, I have 3 different playbooks
>>>> running with a shell script.
>>>>
>>>> First the script runs a playbook aws.yml to start up an instance with a
>>>> static IP address using the ec2 module, and I have it record the instance
>>>> id to a local file
>>>>
>>>> Next, the script runs a normal playbook task to connect to the AWS
>>>> instance using the static IP address.
>>>>
>>>> Lastly, after the tasks are complete on that AWS instance, the script
>>>> calls a last playbook to terminate AWS instance, and I pass the instance id
>>>> as a variable using --extra-vars
>>>>
>>>> How can I create a single playbook that would run the normal playbook
>>>> task against the AWS instance?
>>>>
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Ansible Project" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to ansible...@googlegroups.com.
>>>> To post to this group, send email to ansible...@googlegroups.com.
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/ansible-project/77cb5f2c-1277-4042-b43f-14bb40f3c10a%40googlegroups.com
>>>> <https://groups.google.com/d/msgid/ansible-project/77cb5f2c-1277-4042-b43f-14bb40f3c10a%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>> --
>> You received this message because you are subscribed to the Google Groups
>> "Ansible Project" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to ansible-project+unsubscr...@googlegroups.com.
>> To post to this group, send email to ansible-project@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/dce09a32-f7fb-42fa-8b63-ecfb0ce756af%40googlegroups.com
>> <https://groups.google.com/d/msgid/ansible-project/dce09a32-f7fb-42fa-8b63-ecfb0ce756af%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit h

Re: [ansible-project] Why does this if block + expression result in an undefined variable error?

2019-04-23 Thread Karl Auer
Not sure if the following explanation will help.

Most languages will not continue evaluation of all the components in a
boolean expression once enough have been evaluated to determine the answer.

It's obvious that in "if A and B then C", C will only get evaluated if both
A and B are true. But most languages will not bother evaluating B if A is
false, because if A is false, then "A and B" must be false too; there is no
point evaluating B, because it can't alter the overall value of "A and B".
In such languages, B will only get evaluated if A is *true*, because only
then might evaluating B change the value of the overall expression.

Similarly, in "if A or B then C" there is no point evaluating B if A is
true, because if A is true, "A or B" is true too. It doesn't matter whether
B is true or false. However in this situation, B will only get evaluated if
A is *false*, because only in that case might evaluating B change the value
of the overall expression.

I.e., the order of the subexpressions in a boolean expression can be
important. Sometimes it is useful. A very common idiom in lots of languages
is "test and use" - if the test fails, the use never happens.

Regards, K.

On Wed, Apr 24, 2019 at 12:29 AM Alex Willmer  wrote:

> On Thursday, 18 April 2019 17:34:28 UTC+1, Brian Coca wrote:
>>
>> lazy evaluation prevents the error until the variable is actualy
>> consumed, group1 is empty so [0] is pointing to 'the first host of a
>> list w/o hosts', so the error is correct,
>
>
> I agree, and don't contest this part. If foo is evaluated it should raise
> an error.
>
> you just avoid it in the first case because of the conditional.
>>
>
> T his part confuses me. I both cases the if condition evaluates false. So
> why is foo evaluated in one case but not the other?
>
> Further info: I believe the behaviour I'm seeing is dependent on the
> version of Jinja2. If Jinja2 2.8 is installed then the "{% if false %}"
> case prints "", and the "{% if groups.group1 %}" case raises the error. If
> Jinja2 2.9 or Jinja2 2.10 is installed then both cases raise the Error.
> This is based on testing across Ansible 2.7.{0,5,6,7,8,9,10} using Tox.
>
> With thanks, Alex
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/0afd205f-bca6-4b3b-a525-30917421c0e2%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/0afd205f-bca6-4b3b-a525-30917421c0e2%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Karl Auer

Email  : ka...@2pisoftware.com
Website: http://2pisoftware.com

GPG/PGP : 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E
Previous: 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08SGha8Vy%2BLxPUDVtF_ppEA4P-zosQUH1MC1Y_5U9zcEwQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] can't run playbook - linux aws ec2 controller machine

2019-04-16 Thread Karl Auer
thod=BECOME_METHOD
> privilege escalation method to use (default=sudo),
> valid choices: [ sudo | su | pbrun | pfexec | doas
> |
> dzdo | ksu | runas | pmrun ]
> --become-user=BECOME_USER
> run operations as this user (default=root)
> --ask-sudo-pass ask for sudo password (deprecated, use become)
> --ask-su-pass   ask for su password (deprecated, use become)
> -K, --ask-become-pass
> ask for privilege escalation password
>
> Some modules do not make sense in Ad-Hoc (include, meta, etc)
> ERROR! Extraneous options or arguments
> --
>
>
> [test@ip-172-31-1-143 AQ-Project2]$ ansible --version
> ansible 2.4.6.0
>   config file = /etc/ansible/ansible.cfg
>   configured module search path = [u'/home/test/.ansible/plugins/modules',
> u'/usr/share/ansible/plugins/modules']
>   ansible python module location = /usr/lib/python2.7/site-packages/ansible
>   executable location = /usr/bin/ansible
>   python version = 2.7.14 (default, Jul 26 2018, 19:59:38) [GCC 7.3.1
> 20180303 (Red Hat 7.3.1-5)]
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/1ce633cc-e90a-493d-be0f-3c1ebbd1dded%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/1ce633cc-e90a-493d-be0f-3c1ebbd1dded%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Karl Auer

Email  : ka...@2pisoftware.com
Website: http://2pisoftware.com

GPG/PGP : 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E
Previous: 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08SxtPjGn3die3-bMBwXoVVOJMWTq%3DGXusouLQuHyMGDRg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Problem with linux debian Ansible

2019-04-11 Thread Karl Auer
Yes, I do understand, and this is a problem you will contiue to have unless
you rename the directory.

The problem is harmless - you can still use the directory, it will just
screw up your command prompt.

Unless there is some reason why you cannot rename the directory, you should
rename it to something more standard. Having control characters in
directory names is not good practice.

Regards, K.


On Fri, Apr 12, 2019 at 2:04 AM  wrote:

> Hi,
>
> I have this directory but it's from windows create it in my linux.
>
> In fact, when i write repo + CTL-V then CTL-M   i can open this repertory
> but the curseur is at left and not a right do you understand ?
>
> Thanks for your help Karl !! ;)
>
> Regards,
>
> Le jeudi 11 avril 2019 14:27:31 UTC+2, Karl Auer a écrit :
>>
>> I'm puzzled, why do you want a directory with a carriage return in its
>> name?
>>
>> Anyway - some programs (like ls) will convert control characters to
>> question marks. But most don't, and your prompt string ($PS1) does not. To
>> avoid seeing the carriage return in your prompt, you will have to change
>> your prompt so it does not contain the working directory. For example,
>> substitute this for the last occurrence of "\w" in your PS1 variable:
>>
>>\$(pwd | tr -d \\r\\n)
>>
>> That will just remove carriage returns and linefeeds from the directory
>> name. It will prevent the carriage returns displaying, but you will be
>> unable to tell the difference between repo and repo^M in your prompt.
>>
>> Note that when you do "cd repo?" or "cd repo^M" (you can get "^M" by
>> pressing CTL-V then CTL-M), you do actually change into the directory! You
>> just don't see its name in the prompt. And because "pwd" will not transcode
>> carriage returns, it is hard to see what directory you are in. You can do
>> this to check what directory you are in:
>>
>>pwd | od -a
>>
>> Aside from these output oddities, the directory can be used in the same
>> ways as any other directory.
>>
>> Regards, K.
>>
>>
>>
>> On Thu, Apr 11, 2019 at 9:50 PM  wrote:
>>
>>> Hi Karl Auer,
>>>
>>> First, thank you very much for your answer complet Mister Karl Auer :)
>>>
>>> Exactly, the cursor drops down one line, then to the far left of the
>>> window.
>>>
>>> I would like on issue without rename the name of directory. I would like
>>> only open this repertory but i don't find in internet :(
>>>
>>> Regards,
>>>
>>> Le jeudi 11 avril 2019 10:51:24 UTC+2, Karl Auer a écrit :
>>>>
>>>> I'm not sure what you mean by "I get carriage return". Do you mean that
>>>> when you issue (from the parent directory) the command "cd repertoire?"
>>>> (that's an actual question mark) the cursor drops down one line, then to
>>>> the far left of the window? If so, it looks like you have somehow managed
>>>> to create a directory called "repertoireM" where M is an actual
>>>> carriage return.
>>>>
>>>> *It is harmless* - when in that directory, the remains of your command
>>>> prompt will appear to the right of the cursor and be overtyped by whatever
>>>> you type, but they will have no other effect.
>>>>
>>>> If you do not want to have that carriage return in the directory name,
>>>> just rename the directory:
>>>>
>>>>mv repertoire? repertoireX
>>>> Or whatever name you want instead of repertoireX.
>>>> Alternatively, edit your command prompt. Set PS1 to whatever it is now,
>>>> but get rid or or replace "\w". That is the bit that is being replaced by
>>>> the working directory name and causing the carriage return to be displayed.
>>>> You can set PS1 locally (just in the current terminal) and it will apply
>>>> only to the current window and will be reset when you close that window. If
>>>> you want the change to be permanent, edit ~/.bashrc, look for where PS1 is
>>>> set, and make the change there. It won't take effect until .bashrc is run
>>>> again, of course.
>>>>
>>>> Regards, K.
>>>>
>>>>
>>>> On Thu, Apr 11, 2019 at 6:00 PM  wrote:
>>>>
>>>>> Hi all,
>>>>>
>>>>> I have Debian linux 8.11 (jessie) with Ansible.
>>>>>
>>>>> My problem is that i have tw

Re: [ansible-project] Problem with linux debian Ansible

2019-04-11 Thread Karl Auer
I'm puzzled, why do you want a directory with a carriage return in its name?

Anyway - some programs (like ls) will convert control characters to
question marks. But most don't, and your prompt string ($PS1) does not. To
avoid seeing the carriage return in your prompt, you will have to change
your prompt so it does not contain the working directory. For example,
substitute this for the last occurrence of "\w" in your PS1 variable:

   \$(pwd | tr -d \\r\\n)

That will just remove carriage returns and linefeeds from the directory
name. It will prevent the carriage returns displaying, but you will be
unable to tell the difference between repo and repo^M in your prompt.

Note that when you do "cd repo?" or "cd repo^M" (you can get "^M" by
pressing CTL-V then CTL-M), you do actually change into the directory! You
just don't see its name in the prompt. And because "pwd" will not transcode
carriage returns, it is hard to see what directory you are in. You can do
this to check what directory you are in:

   pwd | od -a

Aside from these output oddities, the directory can be used in the same
ways as any other directory.

Regards, K.



On Thu, Apr 11, 2019 at 9:50 PM  wrote:

> Hi Karl Auer,
>
> First, thank you very much for your answer complet Mister Karl Auer :)
>
> Exactly, the cursor drops down one line, then to the far left of the
> window.
>
> I would like on issue without rename the name of directory. I would like
> only open this repertory but i don't find in internet :(
>
> Regards,
>
> Le jeudi 11 avril 2019 10:51:24 UTC+2, Karl Auer a écrit :
>>
>> I'm not sure what you mean by "I get carriage return". Do you mean that
>> when you issue (from the parent directory) the command "cd repertoire?"
>> (that's an actual question mark) the cursor drops down one line, then to
>> the far left of the window? If so, it looks like you have somehow managed
>> to create a directory called "repertoireM" where M is an actual carriage
>> return.
>>
>> *It is harmless* - when in that directory, the remains of your command
>> prompt will appear to the right of the cursor and be overtyped by whatever
>> you type, but they will have no other effect.
>>
>> If you do not want to have that carriage return in the directory name,
>> just rename the directory:
>>
>>mv repertoire? repertoireX
>> Or whatever name you want instead of repertoireX.
>> Alternatively, edit your command prompt. Set PS1 to whatever it is now,
>> but get rid or or replace "\w". That is the bit that is being replaced by
>> the working directory name and causing the carriage return to be displayed.
>> You can set PS1 locally (just in the current terminal) and it will apply
>> only to the current window and will be reset when you close that window. If
>> you want the change to be permanent, edit ~/.bashrc, look for where PS1 is
>> set, and make the change there. It won't take effect until .bashrc is run
>> again, of course.
>>
>> Regards, K.
>>
>>
>> On Thu, Apr 11, 2019 at 6:00 PM  wrote:
>>
>>> Hi all,
>>>
>>> I have Debian linux 8.11 (jessie) with Ansible.
>>>
>>> My problem is that i have two repertory :
>>>
>>> *repertoire*
>>> *repertoire?*
>>>
>>> The repertory *repertoire?* it was created since windows so there is
>>> surely the character ^M
>>>
>>> when i try open this content with command line "cd repertoire?" i get a
>>> carriage return
>>>
>>> I need this repertory for use in ansible.
>>>
>>> Someone have an idea please !!?
>>>
>>> Thanks community ansible ;)
>>>
>>> Regards,
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Ansible Project" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to ansible...@googlegroups.com.
>>> To post to this group, send email to ansible...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/ansible-project/6a9aa4f5-7b02-4123-9e81-bd77ae8fea97%40googlegroups.com
>>> <https://groups.google.com/d/msgid/ansible-project/6a9aa4f5-7b02-4123-9e81-bd77ae8fea97%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>> --
>> Karl Auer
>>
>> Email  : ka...@2pisoftware.com
>> 

Re: [ansible-project] Problem with linux debian Ansible

2019-04-11 Thread Karl Auer
I'm not sure what you mean by "I get carriage return". Do you mean that
when you issue (from the parent directory) the command "cd repertoire?"
(that's an actual question mark) the cursor drops down one line, then to
the far left of the window? If so, it looks like you have somehow managed
to create a directory called "repertoireM" where M is an actual carriage
return.

*It is harmless* - when in that directory, the remains of your command
prompt will appear to the right of the cursor and be overtyped by whatever
you type, but they will have no other effect.

If you do not want to have that carriage return in the directory name, just
rename the directory:

   mv repertoire? repertoireX
Or whatever name you want instead of repertoireX.
Alternatively, edit your command prompt. Set PS1 to whatever it is now, but
get rid or or replace "\w". That is the bit that is being replaced by the
working directory name and causing the carriage return to be displayed. You
can set PS1 locally (just in the current terminal) and it will apply only
to the current window and will be reset when you close that window. If you
want the change to be permanent, edit ~/.bashrc, look for where PS1 is set,
and make the change there. It won't take effect until .bashrc is run again,
of course.

Regards, K.


On Thu, Apr 11, 2019 at 6:00 PM  wrote:

> Hi all,
>
> I have Debian linux 8.11 (jessie) with Ansible.
>
> My problem is that i have two repertory :
>
> *repertoire*
> *repertoire?*
>
> The repertory *repertoire?* it was created since windows so there is
> surely the character ^M
>
> when i try open this content with command line "cd repertoire?" i get a
> carriage return
>
> I need this repertory for use in ansible.
>
> Someone have an idea please !!?
>
> Thanks community ansible ;)
>
> Regards,
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/6a9aa4f5-7b02-4123-9e81-bd77ae8fea97%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/6a9aa4f5-7b02-4123-9e81-bd77ae8fea97%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Karl Auer

Email  : ka...@2pisoftware.com
Website: http://2pisoftware.com

GPG/PGP : 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E
Previous: 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08TAAmRaKuo8F7J44KFugBo%3DhB%2BHrYirdETvzfcdE%3DpnXg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Re: looping over set of tasks (roles?)

2019-03-24 Thread Karl Auer
If there is some condition that can be tested externally, then why not a
simple script that calls ansible-playbook until that condition obtains?

On Sun, Mar 24, 2019 at 8:37 PM Raghavendra Rao 
wrote:

> Hi. I think this situation hasn't changed in ansible v2.7 as well.
>
> There is no way I can find to repeat a particular task or a set of tasks
> within an existing playbook.
> It would have been great if we could use tags to call some "tagged-tasks
> again" wherever we want in a playbook OR create a new feature like 'goto or
> goback' as discussed in the above threads.
>
> My scenario:
> I have to deal with 3 tasks A, B and C. Here C is dependent on A and B's
> performance. i.e If C's output is not as expected, then again A and B have
> to be repeated again. And somehow I cannot fit this in a
> 'block-rescue-always' structure as its pointless.
>
> Right now, I manage this using 'include_task' option along with 'when'
> conditional. I re-enter A and B tasks into a separate '.yml' file and then
> call it into this playbook using 'include_task' wherever I want.
> This solved my purpose but is ridiculous especially when we have so many
> other options to effectively orchestrate things using ansilble.
>
> Any inputs/thoughts on this would be helpful for me to explore more.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/61c4f6a8-100e-4829-8f01-cc0d72f21800%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/61c4f6a8-100e-4829-8f01-cc0d72f21800%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Karl Auer

Email  : ka...@2pisoftware.com
Website: http://2pisoftware.com

GPG/PGP : 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816
Previous: F0AB 6C70 A49D 1927 6E05 81E7 AD95 268F 2AB6 40EA

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08Sy4_dN3hO5NNhObEx%2BL-oaEzTs423ZVStJfhsvj3ek3A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] How to create a list of dicts

2019-03-13 Thread Karl Auer
As Kai Stian Olstad wrote, I got the target list wrong. The first ocurrence
of "loglist" should  be "logdict", OR (even better) do as Kai suggested and
substitute "logfile_config" for loglist and logdict.

Regards, K.


On Wed, Mar 13, 2019 at 10:08 PM Ashok  wrote:

> The content of the source is very dynamic on each run, hence, going static
> isn't viable.
>
> I tried with your logic, like below:
>
> - name: Form list of dicts
>   set_fact:
> logfile_config: "{{ logf_dest |default([]) +
>  [ {
> 'logfile_name': 'remote.conf',
> 'logfile_pattern': item,
> 'logfile_owner':   'root'
>}
>  ] }}"
>   with_items: "{{ logf_dest }}"
>
>
> - debug:
> var: logfile_config
>
> It doesn't give the desired output. `logfile_config` is:
>
> TASK [debug]
> *
> task path: /home/ansible/playbooks/loghost-new.yml:42
> ok: [log-dvl.vpn] => {
> "logfile_config": [
> "/logs/mx/mail.log",
> "/logs/dyn.log",
> "/logs/apache-servers/other.log",
> {
> "logfile_name": "remote.conf",
> "logfile_owner": "root",
> "logfile_pattern": "/logs/apache-servers/other.log"
> }
> ]
> }
>
> Anything I missed?
>
>
> On Wednesday, 13 March 2019 12:50:31 UTC+5:30, Karl Auer wrote:
>>
>> How dynamic is the content of that source list? One simple approach would
>> be:
>>
>> - logfile_name: remote.conf
>>   logfile_pattern: "{{ logf_dest[0] }}"
>>   logfile_owner: root
>> - logfile_name: remote.conf
>>   logfile_pattern: "{{ logf_dest[1] }}"
>>   logfile_owner: root
>> - logfile_name: remote.conf
>>   logfile_pattern: "{{ logf_dest[2] }}"
>>   logfile_owner: root
>>
>> If the list is not always three items long, you can do it with a loop:
>>
>> - set_fact:
>>  logdict: "{{ loglist |default([]) +
>>[  {
>> 'logfile_name':'remote.conf',
>>   'logfile_pattern': item,
>>  'logfile_owner':   'root'
>> }
>>] }}"
>>   with_items: "{{ logf_dest }}"
>>
>> Anyway, something like that. That's off the top of my head, so you may
>> need to correct the syntax a bit, but you get the idea.
>>
>> Regards, k.
>>
>>
>> On Wed, Mar 13, 2019 at 5:55 PM Ashok  wrote:
>>
>>> Hi All,
>>>
>>> I have a list  ` logf_dest ` (of log files):
>>>
>>> "logf_dest": [
>>> "/logs/mx/mail.log",
>>> "/logs/dyn.log",
>>> "/logs/apache-servers/other.log"
>>> ]
>>>
>>> I need to form a "list of dicts" called ` logfile_config `, like the
>>> below:
>>>
>>> - logfile_name: remote.conf
>>>   logfile_pattern: /logs/mx/mail.log
>>>   logfile_owner: root
>>>
>>>
>>> - logfile_name: remote.conf
>>>   logfile_pattern: /logs/dyn.log
>>>   logfile_owner: root
>>>
>>>
>>> - logfile_name: remote.conf
>>>   logfile_pattern: /logs/apache-servers/other.log
>>>   logfile_owner: root
>>>
>>>
>>> I've come this far in doing so:
>>>
>>> - name: Create list of dicts
>>>   set_fact:
>>> logfile_config: |
>>>{
>>>{% for k in logf_dest %}
>>>logfile_name: remote.conf
>>>logfile_pattern: {{ k }}
>>>logfile_owner: root
>>>{% endfor %}
>>>}
>>>
>>> But, above is obviously not formatted correctly.
>>>
>>> I need help on what I am missing here.
>>>
>>> Thanks in advance.
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Ansible Project" group.
>>> To unsubscribe from this group and stop receiving emails 

Re: [ansible-project] How to create a list of dicts

2019-03-13 Thread Karl Auer
Sorry about that. I did warn you it was off the top of my head :-)

On Wed, Mar 13, 2019 at 11:26 PM Kai Stian Olstad <
ansible-project+l...@olstad.com> wrote:

> On 13.03.2019 12:08, Ashok wrote:
> > The content of the source is very dynamic on each run, hence, going
> > static
> > isn't viable.
> >
> > I tried with your logic, like below:
> >
> > - name: Form list of dicts
> >   set_fact:
> > logfile_config: "{{ logf_dest |default([]) +
>
> This need to be
>logfile_config: "{{ logfile_config |default([]) +
>
> --
> Kai Stian Olstad
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/785924214264966b91e9a158e3fc236b%40olstad.com
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Karl Auer

Email  : ka...@2pisoftware.com
Website: http://2pisoftware.com

GPG/PGP : 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816
Previous: F0AB 6C70 A49D 1927 6E05 81E7 AD95 268F 2AB6 40EA

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08SPF7fwN0DDK4zC-T6nDasWk9zdBt2RwLvBcKHqW7U8bg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] How to create a list of dicts

2019-03-13 Thread Karl Auer
How dynamic is the content of that source list? One simple approach would
be:

- logfile_name: remote.conf
  logfile_pattern: "{{ logf_dest[0] }}"
  logfile_owner: root
- logfile_name: remote.conf
  logfile_pattern: "{{ logf_dest[1] }}"
  logfile_owner: root
- logfile_name: remote.conf
  logfile_pattern: "{{ logf_dest[2] }}"
  logfile_owner: root

If the list is not always three items long, you can do it with a loop:

- set_fact:
 logdict: "{{ loglist |default([]) +
   [  {
'logfile_name':'remote.conf',
  'logfile_pattern': item,
 'logfile_owner':   'root'
}
   ] }}"
  with_items: "{{ logf_dest }}"

Anyway, something like that. That's off the top of my head, so you may need
to correct the syntax a bit, but you get the idea.

Regards, k.


On Wed, Mar 13, 2019 at 5:55 PM Ashok  wrote:

> Hi All,
>
> I have a list  ` logf_dest ` (of log files):
>
> "logf_dest": [
> "/logs/mx/mail.log",
> "/logs/dyn.log",
> "/logs/apache-servers/other.log"
> ]
>
> I need to form a "list of dicts" called ` logfile_config `, like the below:
>
> - logfile_name: remote.conf
>   logfile_pattern: /logs/mx/mail.log
>   logfile_owner: root
>
>
> - logfile_name: remote.conf
>   logfile_pattern: /logs/dyn.log
>   logfile_owner: root
>
>
> - logfile_name: remote.conf
>   logfile_pattern: /logs/apache-servers/other.log
>   logfile_owner: root
>
>
> I've come this far in doing so:
>
> - name: Create list of dicts
>   set_fact:
> logfile_config: |
>{
>{% for k in logf_dest %}
>logfile_name: remote.conf
>logfile_pattern: {{ k }}
>logfile_owner: root
>{% endfor %}
>}
>
> But, above is obviously not formatted correctly.
>
> I need help on what I am missing here.
>
> Thanks in advance.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/61b38102-c346-495f-96e5-cd149800d4f9%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/61b38102-c346-495f-96e5-cd149800d4f9%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Karl Auer

Email  : ka...@2pisoftware.com
Website: http://2pisoftware.com

GPG/PGP : 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816
Previous: F0AB 6C70 A49D 1927 6E05 81E7 AD95 268F 2AB6 40EA

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08Qk9kTLh5WooDzDih0n%2Bf1B7yADicKPBZUjMdVYpGz4iQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Dealing with a half-expected error

2019-02-15 Thread Karl Auer
I've got some code that adds a rule to an AWS security group using the
ec2_group module. The problem is that if the rule I am adding already
exists, Ansible throws an error.

I am a bit puzzled as to why; normally Ansible would just say "good, it's
there already, job done", but in this case it objects. It's always going to
fail on all but the first run.

How can I field an error, inspect it, and then continue with the playbook
if I so choose?

Regards, K.

-- 
Karl Auer

Email  : ka...@2pisoftware.com
Website: http://2pisoftware.com

GPG/PGP : 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816
Previous: F0AB 6C70 A49D 1927 6E05 81E7 AD95 268F 2AB6 40EA

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08RD9%2BtE-aeA6%2BxZbA7vZbZQoOY27Oj2o2wFrqEirpxUpg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] ASG Volume tags

2019-02-14 Thread Karl Auer
Not sure, but you could check out launch templates. There's no way to do it
directly via a launch configuration that I know of.

You CAN do it after the fact by running appropriate userdata scripts, and
there is some discussion out there on the Internet about ways to do this.

You can also use the AWS CLI to tag the volumes after they've been created.
For example, run a cron job that locates untagged volumes, loads up the
instance details and then tags the volumes with e.g. one or more of the
instance tags. That may or may not be some thing you could do with Ansible.

Regards, K.


On Thu, Feb 14, 2019 at 2:37 AM James Morgan  wrote:

> Hi,
>
> Does anybody know how to get tags applied to volumes associated with
> instances created as part of an ASG?
>
> Instances tags are propagated fine, just no way to tag the volumes that I
> can see
>
> Many thanks
>
> James
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/e1025a40-95ce-47f8-bc74-c885f188f00f%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/e1025a40-95ce-47f8-bc74-c885f188f00f%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Karl Auer

Email  : ka...@2pisoftware.com
Website: http://2pisoftware.com

GPG/PGP : 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816
Previous: F0AB 6C70 A49D 1927 6E05 81E7 AD95 268F 2AB6 40EA

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08SkNjZgmBmywe0xjUP%3DCLyXjCbcNa8%3D3MC6az%3Df3qkNeQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Import certificates to aws certificate manager

2019-02-08 Thread Karl Auer
Is there some reason you want to import your own certificate? Certs are
free from AWS for use with load balancers. Very easy to set up, just
specify that ARN to the load baancer module.

At least, it is with ALBs. Not sure about ELBs.

Regards, K.


On Fri, Feb 8, 2019 at 10:29 PM sridhara sri 
wrote:

> Hi how to import certificate into aws certificate manager and get the arn
> number...
>
> am writing the sample ansible code to launch an ELB and add SSL to the
> launched ELB using arn..
>
> or need suggestion to enable SSL on newly launched ELB
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/0e8ffbcc-baac-48e1-97fb-b8d4d685a846%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/0e8ffbcc-baac-48e1-97fb-b8d4d685a846%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Karl Auer

Email  : ka...@2pisoftware.com
Website: http://2pisoftware.com

GPG/PGP : 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816
Previous: F0AB 6C70 A49D 1927 6E05 81E7 AD95 268F 2AB6 40EA

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08TDEydp--AGxuBWVNcRxLq%2BooUYvg7g72YV%3DnK%2B9e%2Bw7A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Tags in loop

2019-01-29 Thread Karl Auer
Great! Then I just told you how to do it.

vars:
   mytags:
  fred: frederick
  rod: roderick

- module_whatever:
 [...]
 tags: "{{ mytags }}"
 [...]

Or if you have the IDs of the resources you want to tag, use the ec2_tag
module.

Regards, K.


On Wed, Jan 30, 2019 at 10:27 AM Rafael Tomelin 
wrote:

> Hi,
>
> This tag in ansible.  I need set key and value (- key: value), but in
> variable.
>
> On Tue, Jan 29, 2019 at 7:36 PM Karl Auer  wrote:
> >
> > What kind of tag? Do you mean an ansible tag, or a tag for e.g. Amazon
> resources?
> >
> > If you mean Ansible tags, I do not know.
> >
> > If you mean AWS tags, most resource modules provide a "tags" attribute,
> if the resource supports tags. Some resources (generally those with IDs)
> can be tagged using the ec2_tag module.
> >
> > Regards, K.
> >
> >
> > On Tue, Jan 29, 2019 at 11:25 PM Rafael Tomelin <
> rafael.tome...@gmail.com> wrote:
> >>
> >> Hi dear,
> >>
> >> I need create tag in my role, this example:
> >>
> >> vars/main.yml
> >> name_variable:
> >> tags:
> >>key1: value1
> >>key2: value2
> >>
> >> in tasks
> >> taks/main.yml
> >>
> >> - name: name my task
> >>   user: name
> >>   tags:
> >>  tags from vars
> >>
> >>
> >> how can create this tags?
> >>
> >>
> >> --
> >> Atenciosamente,
> >>
> >> Rafael Tomelin
> >> Tel.: 51-84104084
> >> Skype: rafael.tomelin
> >>
> >> LPI ID: LPI000191271
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> Groups "Ansible Project" group.
> >> To unsubscribe from this group and stop receiving emails from it, send
> an email to ansible-project+unsubscr...@googlegroups.com.
> >> To post to this group, send email to ansible-project@googlegroups.com.
> >> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAGEUqbBU%2BN0Byj2aLUDLRwCPgLcYN8X%2BA9yMTns4F5QL0okezQ%40mail.gmail.com
> .
> >> For more options, visit https://groups.google.com/d/optout.
> >
> >
> >
> > --
> > Karl Auer
> >
> > Email  : ka...@2pisoftware.com
> > Website: http://2pisoftware.com
> >
> > GPG/PGP : 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816
> > Previous: F0AB 6C70 A49D 1927 6E05 81E7 AD95 268F 2AB6 40EA
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups "Ansible Project" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an email to ansible-project+unsubscr...@googlegroups.com.
> > To post to this group, send email to ansible-project@googlegroups.com.
> > To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08S%3DyOXkTpApiE1om%3D8DcpnT%2Bp8673ZyQshSqeoTAd%2B8iQ%40mail.gmail.com
> .
> > For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
> Atenciosamente,
>
> Rafael Tomelin
> Tel.: 51-84104084
> Skype: rafael.tomelin
>
> LPI ID: LPI000191271
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAGEUqbCX98-Nw_B18MkgSCu87o5oSmHvKdttg4YqnL8%2BB4K8bw%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Karl Auer

Email  : ka...@2pisoftware.com
Website: http://2pisoftware.com

GPG/PGP : 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816
Previous: F0AB 6C70 A49D 1927 6E05 81E7 AD95 268F 2AB6 40EA

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08QVVcjwLxDCDTOuZc0_sLc9s9upM-06_zo-RZnZnE3Yxg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Tags in loop

2019-01-29 Thread Karl Auer
What kind of tag? Do you mean an ansible tag, or a tag for e.g. Amazon
resources?

If you mean Ansible tags, I do not know.

If you mean AWS tags, most resource modules provide a "tags" attribute, if
the resource supports tags. Some resources (generally those with IDs) can
be tagged using the ec2_tag module.

Regards, K.


On Tue, Jan 29, 2019 at 11:25 PM Rafael Tomelin 
wrote:

> Hi dear,
>
> I need create tag in my role, this example:
>
> vars/main.yml
> name_variable:
> tags:
>key1: value1
>key2: value2
>
> in tasks
> taks/main.yml
>
> - name: name my task
>   user: name
>   tags:
>  tags from vars
>
>
> how can create this tags?
>
>
> --
> Atenciosamente,
>
> Rafael Tomelin
> Tel.: 51-84104084
> Skype: rafael.tomelin
>
> LPI ID: LPI000191271
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAGEUqbBU%2BN0Byj2aLUDLRwCPgLcYN8X%2BA9yMTns4F5QL0okezQ%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Karl Auer

Email  : ka...@2pisoftware.com
Website: http://2pisoftware.com

GPG/PGP : 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816
Previous: F0AB 6C70 A49D 1927 6E05 81E7 AD95 268F 2AB6 40EA

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08S%3DyOXkTpApiE1om%3D8DcpnT%2Bp8673ZyQshSqeoTAd%2B8iQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Re: getting error while checking which java using ansible

2019-01-28 Thread Karl Auer
Make a list of possible places that a java executable might be, in order of
preference, and work through the list checking each location in turn. Or
use the shell command I gave you last week to search an entire directory
tree for java executables; checking a list of possible candidates will be a
lot faster though. When you find one, use that executable in future
commands. If you store the information with the host, you can skip the
search next time.

Regards, K.

On Mon, Jan 28, 2019 at 5:24 PM ruben melvin 
wrote:

> I am actually not supposed to add or set anything on that server as it is
> a production server. So setting environment is not an option for me.
> I just need to know the java version using ansible so that it will help me
> a lot in reducing the manual works of my teammates.
>
> I tried out using the below playbook with "java -version" instead of
> "which java" but this time also faced error.
>
> ---
> - name: "checking the java version"
>   hosts: host
>   remote_user: c5115061
>   gather_facts: False
>   become: yes
>   become_user: idmspp
>   become_method: 'sudo'
>
>   tasks:
> - name: which java
>   shell: java -version
> #  args:
> #executable: /usr/java/
>   register: java
>
>
> - debug: msg="{{ java }}"
>
>
> FAILED! => {"changed": true, "cmd": "java -version", "delta":
> "0:00:00.074380", "end": "2019-01-28 06:00:14.656299", "msg": "non-zero
> return code", "rc": 127, "start": "2019-01-28 06:00:14.581919", "stderr":
> "/bin/bash: java: command not found", "stderr_lines": ["/bin/bash: java:
> command not found"], "stdout": "", "stdout_lines": []}
>
>
> Can anyone help me in this?
>
> Thanks,
> Ruben
>
> On Tuesday, 22 January 2019 20:35:06 UTC+5:30, ruben melvin wrote:
>>
>> Hi guys,
>>
>> I am trying to execute below ansible playbook.
>>
>> ---
>> - name: "checking the java version"
>>   hosts: host
>>   remote_user: myremoteuser
>>   gather_facts: False
>>   become: yes
>>   become_user: serveruser
>>   become_method: 'sudo'
>>
>>   tasks:
>> - name: which java
>>   shell: which java
>>   args:
>> executable: /usr/java/
>>   register: java
>>
>>
>> - debug: msg="{{ java }}"
>> ...
>>
>>
>> and getting the below error.
>>
>> FAILED! => {"changed": false, "cmd": "/usr/java/ -c 'which java'", "msg":
>> "[Errno 13] Permission denied", "rc": 13}
>>
>>
>> this is what I execute..
>>
>>
>> ansible-playbook -i hosts java.yml -vv --ask-become-pass
>>
>>
>> I will have to login first using "myremoteuser" and then I have to
>> change the user to "serveruser" and execute the above command.
>>
>> I am able to do this directly on server but not through ansible.
>>
>>
>> Kindly help.
>>
>>
>> Thanks in advance,
>>
>> Ruben
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/49dd72ca-39cc-4b49-afc7-8175ae380dc9%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/49dd72ca-39cc-4b49-afc7-8175ae380dc9%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Karl Auer

Email  : ka...@2pisoftware.com
Website: http://2pisoftware.com

GPG/PGP : 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816
Previous: F0AB 6C70 A49D 1927 6E05 81E7 AD95 268F 2AB6 40EA

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08QMZCZGP%2Bd8F64QKzcD4-HRpW%3DKN%3Dimxabt6c_RhXPG5g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] How to debug why a role is not played?

2019-01-23 Thread Karl Auer
Probably need the actual playbook and actual role to see why this is
happening.

Is the role tagged, if so how? Though if it were tags you'd expect to see
output even when skipped.

Maybe make sure that you are running the playbook you think you are
running, and check that the role that is being skipped is definitely being
referenced by the playbook. Check things like the roles_path. And check
that the contents of the role are not commented out or something silly.

Also, check that the output you expect from this role is the output it will
actually create - maybe you are looking for something that the role is not
actually doing!

Regards, K.


On Thu, Jan 24, 2019 at 8:43 AM kumkum  wrote:

> Hi,
>
> I have a playbook with *one play* that runs *several roles*.
>
> But when I run the playbook, Ansible is *skipping* one of the roles (not
> the first or last, but one in the middle).
> I tried creating a playbook with just that role, and again it's skipped.
> The play has a "pre_tasks" section and those are run.
>
> i.e.,
>
> - hosts: servers
>
>   become: true
>
>   gather_facts: false
>
>   pre_tasks:
>
> - name: Install python-simplejson
>
>   raw: sudo apt-get -y install python-simplejson
>
>   roles:
>
> - the_role
>
>
> I've tried running Ansible with -vvv but it did not tell me why the role
> was skipped.
>
> Thanks for any help.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/485a7cb2-731f-4e61-bd77-fe94eacad1c6%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/485a7cb2-731f-4e61-bd77-fe94eacad1c6%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Karl Auer

Email  : ka...@2pisoftware.com
Website: http://2pisoftware.com

GPG/PGP : 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816
Previous: F0AB 6C70 A49D 1927 6E05 81E7 AD95 268F 2AB6 40EA

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08TE6xBsZC2dSvm8tajtkd2fXwE%2B1XDM-%3DC-dDYg62jzpQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] getting error while checking which java using ansible

2019-01-23 Thread Karl Auer
The command worked. It found several java executables:

/usr/java/jdk64-1.8.0_151/bin/java
/usr/java/jdk64-1.8.0_151/jre/bin/java
/usr/java/jre64-1.8.0_111/bin/java
/usr/java/jre64-1.8.0_111/jre/bin/java

If you look closely at the output you got from your command, you will see
that there is a list of strings called "stdout_lines" that contains the
paths to the java executables that the command located. You can extract
them as simply as result.stdout_lines[0] or whatever.

There were some directories that the find command could not recurse
through, so it reported "permission denied" on those directories.

I'm sorry - I can't offer a complete solution, only ideas.

The most important idea though, is that you almost certainly should not be
searching for an executable you intend to run. You should know where it is.

If your use case requires you to search for java, maybe you can compromise:
Set up a list of likely locations, look for it in each of those locations
in turn, and if it is not found in one of those locations, abort.

If you really want to persist with searching for it, you could use filters
to split up the lines in the stdout result, select only those lines that
match ".*java$" - those paths will be paths to executables. You could for
example run this command:

find -L /usr -executable -type f -name "java" -print 2>/dev/null | grep
"/java$"

That command will discard any errors, and return ONLY lines that refer to
an executable called "java". The command will return zero if there are any
java executables and will fail with  non-zzero code only of there are no
java executables found.

Regards, K.

On Thu, Jan 24, 2019 at 2:12 AM ruben melvin 
wrote:

> I tried to use the above command as per you suggestion and again got the
> permission denied error.
>
> fatal: [ma-idmspp-lapp565]: FAILED! => {"changed": true, "cmd": "find -L
> /usr -executable -type f -name \"java\" -print", "delta": "0:00:01.458827",
> "end": "2019-01-23 15:10:26.161587", "msg": "non-zero return code", "rc":
> 1, "start": "2019-01-23 15:10:24.702760", "stderr": "find:
> '/usr/share/polkit-1/rules.d': Permission denied\nfind:
> '/usr/libexec/initscripts/legacy-actions/auditd': Permission denied\nfind:
> '/usr/tmp/lost+found': Permission denied\nfind:
> '/usr/tmp/.ansible-c5023304': Permission denied\nfind:
> '/usr/tmp/yum-root-a6LSso': Permission denied\nfind:
> '/usr/tmp/systemd-private-8e020ca4b1d1423ea4e25c65b1f20330-ntpd.service-7jH9UJ':
> Permission denied\nfind: '/usr/local/gcs_compliance': Permission
> denied\nfind: '/usr/local/epic/cache': Permission denied\nfind:
> '/usr/local/epic/log': Permission denied\nfind: '/usr/local/lib/asset':
> Permission denied", "stderr_lines": ["find: '/usr/share/polkit-1/rules.d':
> Permission denied", "find:
> '/usr/libexec/initscripts/legacy-actions/auditd': Permission denied",
> "find: '/usr/tmp/lost+found': Permission denied", "find:
> '/usr/tmp/.ansible-c5023304': Permission denied", "find:
> '/usr/tmp/yum-root-a6LSso': Permission denied", "find:
> '/usr/tmp/systemd-private-8e020ca4b1d1423ea4e25c65b1f20330-ntpd.service-7jH9UJ':
> Permission denied", "find: '/usr/local/gcs_compliance': Permission denied",
> "find: '/usr/local/epic/cache': Permission denied", "find:
> '/usr/local/epic/log': Permission denied", "find: '/usr/local/lib/asset':
> Permission denied"], "stdout":
> "/usr/java/jdk64-1.8.0_151/bin/java\n/usr/java/jdk64-1.8.0_151/jre/bin/java\n/usr/java/jre64-1.8.0_111/bin/java\n/usr/java/jre64-1.8.0_111/jre/bin/java",
> "stdout_lines": ["/usr/java/jdk64-1.8.0_151/bin/java",
> "/usr/java/jdk64-1.8.0_151/jre/bin/java",
> "/usr/java/jre64-1.8.0_111/bin/java",
> "/usr/java/jre64-1.8.0_111/jre/bin/java"]}
>
> Kindly help.
> Ruben
>
> On Wednesday, 23 January 2019 20:09:25 UTC+5:30, Karl Auer wrote:
>>
>> It looks as if it's working. It is running the command "which java". The
>> "which" command is unable to find an executable called "java" in the path,
>> so it outputs an appropriate message to stderr and returns a non zero value.
>>
>> It looks as if you are trying to locate the java executable, but that
>> will only work if the executable is in the shell's PATH. If you know what
>> to add

Re: [ansible-project] getting error while checking which java using ansible

2019-01-23 Thread Karl Auer
It looks as if it's working. It is running the command "which java". The
"which" command is unable to find an executable called "java" in the path,
so it outputs an appropriate message to stderr and returns a non zero value.

It looks as if you are trying to locate the java executable, but that will
only work if the executable is in the shell's PATH. If you know what to add
to the PATH variable, you probably no longer need to use which to find java
:-)

If you know roughly where it is, e.g., under /usr somewhere, you could use
find to locate it:

   find -L /usr -executable -type f -name "java" -print

But to be honest, if you will be running java, you probably need to know
exactly which executable you should be running. Otherwise you will have to
run a battery of tests to make sure that the executable you find is the
right executable (version, architecture etc)

Regards, K.

On Thu, Jan 24, 2019 at 12:45 AM ruben melvin 
wrote:

> I tried removing the args and executable, then while trying to execute
> again I am getting an error below.
>
> {"changed": true, "cmd": "which java", "delta": "0:00:00.074712", "end":
> "2019-01-23 13:41:10.748039", "msg": "non-zero return code", "rc": 1,
> "start": "2019-01-23 13:41:10.673327", "stderr": "which: no java in
> (/usr/bin:/bin:/usr/sbin:/sbin)", "stderr_lines": ["which: no java in
> (/usr/bin:/bin:/usr/sbin:/sbin)"], "stdout": "", "stdout_lines": []}
>
> Kindly help.
> Ruben
>
> On Wednesday, 23 January 2019 02:06:43 UTC+5:30, Kai Stian Olstad wrote:
>>
>> On Tuesday, 22 January 2019 16:05:06 CET ruben melvin wrote:
>> > Hi guys,
>> >
>> > I am trying to execute below ansible playbook.
>> >
>> > ---
>> > - name: "checking the java version"
>> >   hosts: host
>> >   remote_user: myremoteuser
>> >   gather_facts: False
>> >   become: yes
>> >   become_user: serveruser
>> >   become_method: 'sudo'
>> >
>> >   tasks:
>> > - name: which java
>> >   shell: which java
>> >   args:
>> > executable: /usr/java/
>> >   register: java
>>
>> Here you are trying to run the directory /usr/java/
>> just remove the args and executable and it should work.
>>
>>
>> --
>> Kai Stian Olstad
>>
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/527b1756-839f-4b6d-9660-ee6745f7aa71%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/527b1756-839f-4b6d-9660-ee6745f7aa71%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Karl Auer

Email  : ka...@2pisoftware.com
Website: http://2pisoftware.com

GPG/PGP : 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816
Previous: F0AB 6C70 A49D 1927 6E05 81E7 AD95 268F 2AB6 40EA

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08Qo9w3itrPuW4yJMYdQDntw4mv2Nk2Jd8SWfwCO%2B46%2BCw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] ec2_vpc_route_table playbook error was: 'dict object' has no attribute subnet

2019-01-22 Thread Karl Auer
Use debug statements so that you know what is in "
existing_nat_gateways.result" and "public_subnets_to_az".

It looks to me as if there is no element called "subnet-0facefaceface9" in
the dictionary "public_subnets_to_az" (that is a very cool subnet ID by the
way).

Regards, K.

On Tue, Jan 22, 2019 at 10:51 PM Steve Button 
wrote:

> I have a previously working piece of Ansible that I've inherited for a
> previous contractor, and I'm getting an error message that doesn't lead me
> in the right direction. I have tried searching for a few days now, with no
> joy, and my colleagues can't figure it out either.
>
>
> The Ansible in question is :-
>
>
> - name: Routes | Set up NAT-protected route table
>   ec2_vpc_route_table:
> vpc_id: "{{ ec2_vpc_net_reg.vpc.id }}"
> region: "{{ vpc_region }}"
> tags:
>   Name: "Internal {{ item.subnet_id }}"
> subnets:
>   - "{{ az_to_private_sub[public_subnets_to_az[item.subnet_id]] }}"
>   - "{{ az_to_private_data_sub[public_subnets_to_az[item.subnet_id]] }}"
> routes:
>   - dest: 0.0.0.0/0
> gateway_id: "{{ item.nat_gateway_id }}"
>   loop: "{{ existing_nat_gateways.result|flatten(levels=1) }}"
>   #with_items: "{{ existing_nat_gateways.result }}"
>   register: nat_route_table
>   retry: 2
>   delay: 10
>
>
> And the error message is :-
>
>
> fatal: [localhost]: FAILED! => {"msg": "The task includes an option with an 
> undefined variable. The error was: 'dict object' has no attribute 
> u'subnet-0facefaceface9'\n\n
>
> The error appears to have been in 
> '/cup/core-kubernetes-linux/ansible/roles/aws_vpc/tasks/routes.yml': line 62, 
> column 3, but may\n
>
> be elsewhere in the file depending on the exact syntax problem.\n\n
>
> The offending line appears to be:\n\n\n
>
> - name: Routes | Set up NAT-protected route table\n
>
>   ^ here\n
>
> "}
>
>
> I have added some carriage returns to make it a bit more readable.
>
>
> I have tried adding extra debug, for az_to_private_sub and
> public_subnet_to_az, and these look OK. I've tried reading the docs
> <https://docs.ansible.com/ansible/2.5/user_guide/playbooks_loops.html#using-register-with-a-loop>
>
> Can anyone suggest where I should look next?
>
>
> Thanks!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/e1bd8cda-ae5a-4a3b-bcf3-13293d72c5b3%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/e1bd8cda-ae5a-4a3b-bcf3-13293d72c5b3%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Karl Auer

Email  : ka...@2pisoftware.com
Website: http://2pisoftware.com

GPG/PGP : 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816
Previous: F0AB 6C70 A49D 1927 6E05 81E7 AD95 268F 2AB6 40EA

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08TQHN2jMKoMjci8xSY0wQ5x1QCCi1_sdos%2B%3DtKOLWC2%2Bw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] PS Script Not Installing RDS

2019-01-18 Thread Karl Auer
I'm not a Windows peson at all, but it looks to me a bit as if you may not
be waiting long enough after the reboot? To test this, just put in a fixed
(say) two minute delay to make absolutely certain; f that makes a
difference you can work on fine-tuning the delay and/or detecting readiness.

The other possibility is the variables in the second script - you might
like to add code to the script to output the value of "$servername" to a
file, then inspect the file when the script has been run. And/or
experimentally hardcode a servername just to see if it then works.

Thirdly, what if anything is in the variable "RDSInstall" after the script
has been run? A debug statement in your Ansible script might help there.

Regards, K.




On Sat, Jan 19, 2019 at 5:12 AM DC  wrote:

> Hello,
>
> I am trying to automate building an MS RDS Server 2016.  The automation of
> the server build works great up until the last part when it tries to
> install RDS.  Two scripts run separately to install RDS, the first one
> installs the RDS feature, and then Ansible should restart the server after
> the feature gets installed. The first PS script below is not running when
> called on by the Ansible playbook and it does not restart the server as
> well.
>
> *First PS Script that Runs*
> Add-WindowsFeature –Name RDS-RD-Server –IncludeAllSubFeature
>
>
> *After the server bounces the next PS script to install RDS and configure
> the deployment.*
> Enter code here...$servername=(Get-WmiObject win32_computersystem).
> DNSHostName+"."+(Get-WmiObject win32_computersystem).Domain
>
> Import-Module RemoteDesktop
>
> New-RDSessionDeployment -ConnectionBroker "$servername" -WebAccessServer
> "$servername" -SessionHost "$servername"
>
> New-RDSessionCollection -CollectionName "LTS" -SessionHost "$servername"
> -ConnectionBroker "$servername"
>
> Set-RDSessionCollectionConfiguration -CollectionName "LTS" -UserGroup
> "directory\RDS-Users" -ClientDeviceRedirectionOptions 0x
> -ClientPrinterRedirected $False
>
>
> Both scripts get copied to a temp folder on the server correctly via
> Ansible.  Both scripts work perfectly when I run them from the PS editor
> but when I try to use Ansible they do not work.  The 2nd script should take
> 5-7 minutes to install RDS, it finishes within seconds   I am starting to
> think it is the way the scripts are executing since it works perfectly in
> the PS editor but does not work when being called on by Ansible.  Any
> suggestions on how to troubleshoot further?
>
> *Here is the Main.yml file to install RDS*
> - name: Copy Windows Feature installation script
>   win_copy:
> src: TS_Script1.ps1
> dest: c:\temp\TS_Script1.ps1
>
> - name: Install Windows Feature installation script
>   win_shell: c:\temp\TS_Script1.ps1
>   register: result
>
> - name: Reboot from Windows feature install
>   win_reboot:
>   when: result == "Completed"
>
> #Wait for the machine to reboot from installing the windows features
> - name: Waiting for reboot
>   local_action: shell ansible -u {{ansible_user_id}} -m ping {{
> inventory_hostname }}
>   register: result
>   until: result.rc == 0
>   retries: 30
>   delay: 10
>
> - name: Copy RDS installation script
>   win_copy:
> src: TS_Script2_Install_RDS.ps1
> dest: c:\temp\TS_Script2_Install_RDS.ps1
>
> - name: Install RDS installation script
>   win_shell: c:\temp\TS_Script2_Install_RDS.ps1
>   register: RDSInstall
>
> - name: Reboot from Windows feature install
>   win_reboot:
>   when: RDSInstall == "Completed"
>
>
>
>
> Thanks in Advance!!
> DC
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/ee20a3da-7b96-461f-8839-435ffd4f9366%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/ee20a3da-7b96-461f-8839-435ffd4f9366%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Karl Auer

Email  : ka...@2pisoftware.com
Website: http://2pisoftware.com

GPG/PGP : 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816
Previous: F0AB 6C70 A49D 1927 6E05 81E7 AD95 268F 2AB6 40EA

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08TK69L6dDGzaX8bcLyBg0rhrv60dpXpniRRO617qSim8A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] S3 error: Requests specifying Server Side Encryption with AWS KMS managed keys require AWS Signature Version 4

2019-01-12 Thread Karl Auer
I haven't done this myself, so everything I say may be wrong. The following
is just from reading some doco and general experience.

Make sure you are running the latest and greatest versions of everything.
In particular, the boto3 library. I don't know how to check that, but
someone else here will. v4 keys have been around for a couple of years, so
if you installed Ansible recently you should probably have the required
versions.

Make sure you explicitly specify v4 keys when creating objects.

I would be looking at (probably) the values you are passing in to
template_parameters.

It might also we worth seeing if you can create the desired change set
manually, either via the console or via the AWS CLI, just to check you
really do have the parameters right.

Regards, K.


On Sun, Jan 13, 2019 at 12:40 AM Kishore Ponniah  wrote:

> Hi Karl,
>
> Please find the playbook below:
>
> - name: create
> rxgt-ps-cross-account-iam-atlas-developer-roles changeset
>   cloudformation:
> stack_name: "rxgt-ps-cross-account-iam-atlas-developer-roles"
> state: present
> region: "{{ account_config.1 }}"
> aws_access_key: "{{ account_config.0.sts_creds.access_key }}"
> aws_secret_key: "{{ account_config.0.sts_creds.secret_key }}"
> security_token: "{{ account_config.0.sts_creds.session_token }}"
> create_changeset: true
> changeset_name: "{{ cf_changeset_name }}"
> template_url: "
> https://s3-eu-west-1.amazonaws.com//cloudformation/xx-developer-roles.yaml
> "
> template_parameters: "{{
> account_config.0.account_config.stacks['rxgt-ps-cross-account-iam-atlas-developer-roles'].params
> }}"
> termination_protection: no
> tags: "{{ global_tags |
> combine(account_config.0.account_config.stacks['rxgt-ps-cross-account-iam-atlas-developer-roles'].override_tags,
> recursive=True) }}"
>   loop: "{{
> assumed_roles_with_account_config.results|subelements('account_config.regions',
> skip_missing=True) }}"
>   loop_control:
> loop_var: account_config
> label: "{{ account_config.0.account_config.account_alias }}:{{
> account_config.1 }}"
>   tags:
> rxgt-ps-identity-stack-deploy
>
> - name: create rxgt-ps-cross-account-iam-atlas-developer-roles stack
>   cloudformation:
> stack_name: "rxgt-ps-cross-account-iam-atlas-developer-roles"
> state: present
> region: "{{ account_config.1 }}"
> aws_access_key: "{{ account_config.0.sts_creds.access_key }}"
> aws_secret_key: "{{ account_config.0.sts_creds.secret_key }}"
> security_token: "{{ account_config.0.sts_creds.session_token }}"
> create_changeset: false
> changeset_name: "{{ cf_changeset_name }}"
> template_url: "
> https://s3-eu-west-1.amazonaws.com//cloudformation/xx-developer-roles.yaml
> "
> template_parameters: "{{
> account_config.0.account_config.stacks['rxgt-ps-cross-account-iam-atlas-developer-roles'].params
> }}"
> termination_protection: no
> tags: "{{ global_tags |
> combine(account_config.0.account_config.stacks['rxgt-ps-cross-account-iam-atlas-developer-roles'].override_tags,
> recursive=True) }}"
>   loop: "{{
> assumed_roles_with_account_config.results|subelements('account_config.regions',
> skip_missing=True) }}"
>   loop_control:
> loop_var: account_config
> label: "{{ account_config.0.account_config.account_alias }}:{{
> account_config.1 }}"
>   when: with_stack_deploy
>   tags:
> rxgt-ps-identity-stack-deploy
>
> ===
> Error:
>
> TASK [create rxgt-ps-cross-account-iam-atlas-developer-roles changeset]
> 
> An exception occurred during task execution. To see the full traceback,
> use -vvv. The error was: For more information check
> http://docs.aws.amazon.com/AmazonS3/latest/API/ErrorResponses.html
> "Failed to create change set: : An error occurred
> (ValidationError) when calling the CreateChangeSet operation: S3 error:
> Requests specifying Server Side Encryption with AWS KMS managed keys
> require AWS Signature Version 4.\nFor more information check
> http://docs.aws.amazon.com/AmazonS3/latest/API/ErrorResponses.html"}
>
> Thanks
> Kishore
>
>
> On Friday, Januar

Re: [ansible-project] S3 error: Requests specifying Server Side Encryption with AWS KMS managed keys require AWS Signature Version 4

2019-01-11 Thread Karl Auer
You need to provide the actual playbook and the actual error. Use a
fixed-width font when posting the playbook.

On Sat, Jan 12, 2019 at 2:48 AM Kishore Ponniah  wrote:

> Hi All,
>
> The template body has exceeded the maximum limit of 51200 bytes, so I
> wanted to upload the template to an encrypted s3 bucket. When I run the
> playbook it gives an error to explicitly mention s3v4. My config file has a
> line for s3 v4 but still, it shows the same error. I have tested using a
> non-encrypted bucket and works fine.
>
> Could someone please help?
>
> My config file below: I am having 2 profiles because I have to run a SAML
> authentication to assume a role in build account and the deployment runs
> from the build account. I tried to add the s3 line in those 2 profiles but
> ended up with same error.
>
> [profile federated-login]
> region = eu-west-1
> output = json
> [profile federated-build]
> region = eu-west-1
> output = json
> s3 =
> signature_version = s3v4
>
> Thanks
> Kishore
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/36c62048-0a24-422e-823e-ad7dbc1d2d8a%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/36c62048-0a24-422e-823e-ad7dbc1d2d8a%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Karl Auer

Email  : ka...@2pisoftware.com
Website: http://2pisoftware.com

GPG/PGP : 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816
Previous: F0AB 6C70 A49D 1927 6E05 81E7 AD95 268F 2AB6 40EA

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08TB-pwO0P9_MisJjAzb38BexafcA5tv7Cs3DeoeWBYr%2Bw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Re: How to randomize hosts but not repeat the ones that already were selected

2019-01-09 Thread Karl Auer
Yes - so shuffle the pool, then use the first host from the pool for the
first task, the second host from the pool for the second task, the third
host from the pool for the third task and so on.

You can either specify the offset in the pool for each successive task, or
slice the pool between tasks.

Regards, K.


On Thu, Jan 10, 2019 at 2:21 AM Francis Santos  wrote:

> Nop, the idea is to randomize all hosts.
> For example,
>
> POOL: host1 host2 host3
> I randomize, host2 is chosen
> I randomize again, but now host2 cannot be selected.
>
> POOL: host1 host3
> I randomize, host1 is chosen
>
> POOL: host3
> I randomize, host3 is chosen
>
> Once all hosts are chosen I can start the pool again.
>
> POOL: host1 host2 host3
>
> On Wed, Jan 9, 2019 at 12:45 PM Tony Chia  wrote:
>
>> Are you trying to run the playbook on  a list of randomized hosts except
>> the first and 2nd host?
>>
>> Maybe you can try
>> - hosts: "{{ (groups['all'] | shuffle)[2:] }}"
>>
>> See the following for more details
>> https://docs.ansible.com/ansible/latest/user_guide/intro_patterns.html
>>
>> On Wednesday, January 9, 2019 at 5:49:56 AM UTC-8, Francis Santos wrote:
>>>
>>> Hi all,
>>>
>>> With this script I can randomize any host:
>>>
>>> ---
>>>
>>> - hosts: "{{ (groups['all'] | shuffle)[0:1] }}"
>>>   become: true
>>>   vars:
>>>- ansible_sudo_pass: 
>>>
>>> How can I add the proposition to skip the ones that were selected? So I
>>> can use the whole pool of hosts before selecting them again.
>>>
>>>
>>> --
>> You received this message because you are subscribed to the Google Groups
>> "Ansible Project" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to ansible-project+unsubscr...@googlegroups.com.
>> To post to this group, send email to ansible-project@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/22d17f59-2a99-42ff-9064-f6c72c20dc93%40googlegroups.com
>> <https://groups.google.com/d/msgid/ansible-project/22d17f59-2a99-42ff-9064-f6c72c20dc93%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
>
> Atenciosamente/ Regards/ Mit freundlichen Grüßen
>
>
> *_ **Frank Santos*
>
> Phone: +55 11 996001909
> skaven...@gmail.com 
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAAnOJNYfRmwDPK_1F8zOd%2BNDQ4HsC9%2BXOheCmm8gBM1ZLYG%2BEQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CAAnOJNYfRmwDPK_1F8zOd%2BNDQ4HsC9%2BXOheCmm8gBM1ZLYG%2BEQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Karl Auer

Email  : ka...@2pisoftware.com
Website: http://2pisoftware.com

GPG/PGP : 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816
Previous: F0AB 6C70 A49D 1927 6E05 81E7 AD95 268F 2AB6 40EA

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08RwnNuCC80zX82gkX%3DCwf3UCmcLYwqBW4xXFRznLp1zSg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] How to randomize hosts but not repeat the ones that already were selected

2019-01-09 Thread Karl Auer
Do you mean that you want to work through all the hosts in a random order?

If so, just shuffle the list, then work through the list in shuffled order.

Regards, K.


On Thu, Jan 10, 2019 at 12:50 AM Francis Santos  wrote:

> Hi all,
>
> With this script I can randomize any host:
>
> ---
>
> - hosts: "{{ (groups['all'] | shuffle)[0:1] }}"
>   become: true
>   vars:
>- ansible_sudo_pass: 
>
> How can I add the proposition to skip the ones that were selected? So I
> can use the whole pool of hosts before selecting them again.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/df4e3888-a175-4456-a607-5bf62a8a4563%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/df4e3888-a175-4456-a607-5bf62a8a4563%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Karl Auer

Email  : ka...@2pisoftware.com
Website: http://2pisoftware.com

GPG/PGP : 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816
Previous: F0AB 6C70 A49D 1927 6E05 81E7 AD95 268F 2AB6 40EA

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08RDctKtg%3DJowgpE3VJT79h0scBjV0ndXfnP742Obrvs5Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Re: 'ERROR!' Telnet 'is not a valid attribute to play

2019-01-09 Thread Karl Auer
Please repost using a fixed width font so we can check your indentation.
Make sure you post your ENTIRE playbook.

Also, YAML code should always start with three hyphens on a line by
themselves.

Regards, K.


On Wed, Jan 9, 2019 at 10:30 PM Eduardo Nunes Pereira 
wrote:

> Hi,
>
> First of all thanks for the answers, below is my playbook and then the
> error message.
>
>
> ## Playbook
>
> - name: Coletct Information Switches
>   connection: network_cli
>   gather_facts: false
>   hosts: lab_telnet
>   tasks:
>
> - name: send configuration commands to IOS
>   telnet:
> user: admin
> password: 
> login_prompt: "Username: "
> prompts:
>   - "[>|#]"
> command:
>   - terminal length 0
>   - show run
>
> # Error message
>
> root@DESKTOP-5B1T804:/etc/ansible# ansible-playbook telnet.yml
> ERROR! 'telnet' is not a valid attribute for a Play
>
> The error appears to have been in '/etc/ansible/telnet.yml': line 8,
> column 3, but may
> be elsewhere in the file depending on the exact syntax problem.
>
> The offending line appears to be:
>
>
> - name: send configuration commands to IOS
>   ^ here
>
>
>
>
>
> Em terça-feira, 8 de janeiro de 2019 16:54:58 UTC-2, Eduardo Nunes Pereira
> escreveu:
>>
>> Hello Everyone,
>>
>>
>> I use ansible 2.7, I'm trying to use the 'telnet' module to connect to
>> Cisco devices with IOS but it has the following error: '*ERROR!' Telnet
>> 'is not a valid attribute to play "*any ideas?
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/e29e5dc4-718c-42fe-bf0f-37b598ddee1c%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/e29e5dc4-718c-42fe-bf0f-37b598ddee1c%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Karl Auer

Email  : ka...@2pisoftware.com
Website: http://2pisoftware.com

GPG/PGP : 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816
Previous: F0AB 6C70 A49D 1927 6E05 81E7 AD95 268F 2AB6 40EA

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08QMA%2BQUysE3AUrJ_aADZ9W9%3DuGK8ZU-eaOS_VeQOuFZ4g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Id from multiple machines?

2019-01-08 Thread Karl Auer
I am pretty sure that if you loop, the registered variable will contain a
list of results, one from each iteration.

- name: Retrieve Orchid MID
uri:
  url: "{{ item.url }}"
  force_basic_auth: yes
  user: admin
  password: "{{ item.password }}"
  timeout: 20
with_items: "{{ my_list_of_urls }}"
register: machineids

Your list would look like this:

vars:
   my_list_of_urls:
  - url: url_1
password: password_1
  - url: url_2
password: password_2
  - url: url_3
password: password_3

And afterwards, machineids should contain a list of machineid results. Use
debug to check the exact internal structure of the variable.
I HAVE NOT TESTED THIS, it is just a guess.

Regards, K.

On Wed, Jan 9, 2019 at 8:22 AM  wrote:

> Hi.  I'm attempting to retrieve a specific id from multiple machines with
> the uri module.
>
> The below ansible tasks can achieve the operation on one machine.
>
> What is the best way to retrieve the ID from several machines?
>
>
>  - name: Retrieve Orchid MID
> uri:
>   url: "{{ myurl }}"
>   force_basic_auth: yes
>   user: admin
>   password: "{{ mypassword }}"
>   timeout: 20
> register: machineid
>
>   - name: DEBUG Retrieve Orchid MID
> debug:
>   msg: "{{ machineid.json.orchids[0].mid }}"
>
> --
Karl Auer

Email  : ka...@2pisoftware.com
Website: http://2pisoftware.com

GPG/PGP : 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816
Previous: F0AB 6C70 A49D 1927 6E05 81E7 AD95 268F 2AB6 40EA

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08QYqy%3DsfpkwToa7mkMq70LWMpVRhQTNuaXpnpUQkm29ZA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Looping through a dictionary

2019-01-08 Thread Karl Auer
As Kia Stan Olstad already said, you definitely need to be using with_items,
because int_output.interfaces is a list (according to the information you
have supplied).

To make sure that you are referencing the correct variable, add a debug
statement immediately before your "display output' task that just outputs
int_output:

- debug:
var: int_output

The error you are seeing always means that the variable you are using does
not contain what you think it contains, that you are using the wrong
variable, or that you are incorrectly dereferencing the contents of the
variable. The above debug statement should help you decide which.

Regards, K.

On Wed, Jan 9, 2019 at 2:32 AM Spiro Mitsialis 
wrote:

> Hi,
> I have a dictionary and I need to set through it to extract data but
> cannot figure out how to do it.
>
> Dictionary looks like:
> "int_output": {
> "interfaces": [
> {
> "ipaddress": "unassigned",
> "method": "NVRAM",
> "name": "Vlan1",
> "ok": "YES",
> "protocol": "down",
> "status": "administratively down"
> },
> {
> "ipaddress": "172.31.35.8",
> "method": "NVRAM",
> "name": "Vlan99",
> "ok": "YES",
> "protocol": "up",
> "status": "up"
> },
> {
> "ipaddress": "unassigned",
> "method": "NVRAM",
> "name": "Vlan252",
> "ok": "YES",
> "protocol": "down",
> "status": "administratively down"
> }
> ]
> }
>
>
> I've tried using with_item and now trying with with_dict but cannot figure
> out how to make it work.
>
> ...
> - name: display output
>   debug:
> var: "Name is {{ item.name }} and status is {{ item.status }}"
>   with_dict: "{{ int_output.interfaces[0] }}"
>
> The above gives:
> TASK [display output]
> ***
> fatal: [burnside-poc-sw8.gw.mcgill.ca]: FAILED! => {"msg": "The task
> includes an option with an undefined variable. The error was   : 'dict
> object' has no attribute 'name'\n\nThe error appears to have been in
> '/show_int_brief.yml': line 32, column 7, but may\nbe elsewhere in the file
> depending on the exact syntax problem.\n\nThe offending line appears to
> be:\n\n   \n- name: display output\n  ^ here\n"}
>
>
> Also tried:
> - name: display output
>   debug:
> var: "Name is {{ item.name }} and status is {{ item.status }}"
>   with_dict:  int_output.interfaces[0]
>
> Above gives:
> TASK [display output]
> **
> fatal: [burnside-poc-sw8.gw.mcgill.ca]: FAILED! => {"msg": "with_dict
> expects a dict"}
>
> Any ideas good be appreciated.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/d2f0f045-3228-40e9-ada1-d5f0dc5dd7a4%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/d2f0f045-3228-40e9-ada1-d5f0dc5dd7a4%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Karl Auer

Email  : ka...@2pisoftware.com
Website: http://2pisoftware.com

GPG/PGP : 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816
Previous: F0AB 6C70 A49D 1927 6E05 81E7 AD95 268F 2AB6 40EA

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08RfRYwU%3D7N0uJyuYoQ0EoLfPRcZ1Y5ShkQBOSBPwe16hw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Re: Template format error: YAML not well-formed.

2019-01-07 Thread Karl Auer
What is the problem that it reports on line 22?

When posting code, please post in a fixed-width font if you can. Makes it
easier to check indentation.

Regards, K.


On Tue, Jan 8, 2019 at 11:58 AM goforawalktwice 
wrote:

> hi, when I paste that YAML to
>
> https://jsonformatter.org/yaml-validator
>
> it reckons line 22 is a problem - the second -name entry. When I remove
> from line 22 down it reckons it's valid YAML.
>
> Regards, Straff
>
>
>
> On Tuesday, January 8, 2019 at 5:34:25 AM UTC+13, Kishore Ponniah wrote:
>>
>> Hi all,
>>
>> My cloudformation template has exceeded the template body limit more than
>> 51200 bytes and I am trying to upload to s3 and deploy using cross account.
>> I used template_url parameter in the playbook but giving an error. Before
>> adding template_url, I had template_body which was working fine. I have
>> only replaced template_body to template_url.
>>
>> Please find the playbook below:
>>
>> - name: create xx---xx-iam-atlas-developer-roles changeset
>>   cloudformation:
>> stack_name: "xx---xx-iam-atlas-developer-roles"
>> state: present
>> region: "{{ account_config.1 }}"
>> aws_access_key: "{{ account_config.0.sts_creds.access_key }}"
>> aws_secret_key: "{{ account_config.0.sts_creds.secret_key }}"
>> security_token: "{{ account_config.0.sts_creds.session_token }}"
>> create_changeset: true
>> changeset_name: "{{ cf_changeset_name }}"
>> template_url: "
>> https://s3.console.aws.amazon.com/s3/buckets/xx//cloudformation/xxx/xx---xx-iam-atlas-developer-roles.yaml
>> "
>> template_parameters: "{{
>> account_config.0.account_config.stacks[' 
>> xx---xx-iam-atlas-developer-roles'].params
>> }}"
>> termination_protection: no
>> tags: "{{ global_tags |
>> combine(account_config.0.account_config.stacks[' 
>> xx---xx-iam-atlas-developer-roles'].override_tags,
>> recursive=True) }}"
>>   loop: "{{
>> assumed_roles_with_account_config.results|subelements('account_config.regions',
>> skip_missing=True) }}"
>>   loop_control:
>> loop_var: account_config
>> label: "{{ account_config.0.account_config.account_alias }}:{{
>> account_config.1 }}"
>>   tags:
>> rxgt-ps-identity-stack-deploy
>>
>> - name: create xx---xx-iam-atlas-developer-roles stack
>>   cloudformation:
>> stack_name: "xx---xx-iam-atlas-developer-roles"
>> state: present
>> region: "{{ account_config.1 }}"
>> aws_access_key: "{{ account_config.0.sts_creds.access_key }}"
>> aws_secret_key: "{{ account_config.0.sts_creds.secret_key }}"
>> security_token: "{{ account_config.0.sts_creds.session_token }}"
>> create_changeset: false
>> changeset_name: "{{ cf_changeset_name }}"
>> template_url: "
>> https://s3.console.aws.amazon.com/s3/buckets/xx//cloudformation/xxx/xx---xx-iam-atlas-developer-roles.yaml
>> "
>> template_parameters: "{{
>> account_config.0.account_config.stacks['xx---xx-iam-atlas-developer-roles'].params
>> }}"
>> termination_protection: no
>> tags: "{{ global_tags |
>> combine(account_config.0.account_config.stacks['xx---xx-iam-atlas-developer-roles'].override_tags,
>> recursive=True) }}"
>>   # Convert to a list of dicts duplicated per region. See
>> https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html#subelements-filter
>>   loop: "{{
>> assumed_roles_with_account_config.results|subelements('account_config.regions',
>> skip_missing=True) }}"
>>   loop_control:
>> loop_var: account_config
>> label: "{{ account_config.0.account_config.account_alias }}:{{
>> account_config.1 }}"
>>   when: with_stack_deploy
>>   tags:
>> rxgt-ps-identity-stack-deploy
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails f

Re: [ansible-project] with_sequence run a line only once

2019-01-05 Thread Karl Auer
When in the sequence do you want to specify the size, and what size(s)
should the other volumes be if no size is specified?

I.e., what are you trying to achieve?

Regards, K.


On Sun, Jan 6, 2019 at 1:44 AM Piyush Bansal 
wrote:

> Hello Karl,
>
> Here is the task which I want to loop over but need to run "size: XX" line
> only once.
>
> - name: Create Virtual Volume
>hpe3par_volume:
> volume_name: "vv_3par_{{item}}"
> cpg: ""
> state: "present"
> size: "1000"
> size_unit: "GiB"
>    with_sequence: start=1 end={{item10}}
>ignore_errors: True
>
> On Sat, Jan 5, 2019 at 8:03 PM Karl Auer  wrote:
>
>> Please provide sample code, or pseudocode
>>
>> On Sun, Jan 6, 2019 at 12:08 AM Piyush Bansal <
>> bansalpiyush.198...@gmail.com> wrote:
>>
>>> Hello,
>>>
>>> I am trying to loop over a task using "with_sequence" and I need to make
>>> it work such that it run one specific line only once but rest of the lines
>>> it executes as normal times.
>>> It not succeeding or I am not able to figure out how to do it.
>>> Please advise
>>>
>>> Ansible 2.7.5
>>> Python: 3.6.6
>>> CentOS
>>> Target Host: HP3PAR storage
>>>
>>> Activity: I need to create 800 LUNs with different capacity
>>>
>>> Thanks,
>>> Piyush
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Ansible Project" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to ansible-project+unsubscr...@googlegroups.com.
>>> To post to this group, send email to ansible-project@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/ansible-project/CA%2BLLie4kwRpuZ1HeAPtgaRUFj7G1N%3D4DyE2pXwj%2BtjoxbFGf4Q%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/ansible-project/CA%2BLLie4kwRpuZ1HeAPtgaRUFj7G1N%3D4DyE2pXwj%2BtjoxbFGf4Q%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>> --
>> Karl Auer
>>
>> Email  : ka...@2pisoftware.com
>> Website: http://2pisoftware.com
>>
>> GPG/PGP : 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816
>> Previous: F0AB 6C70 A49D 1927 6E05 81E7 AD95 268F 2AB6 40EA
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Ansible Project" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to ansible-project+unsubscr...@googlegroups.com.
>> To post to this group, send email to ansible-project@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08QNMr1vG9nKd7TxoSHMHmFpG5bmFMh5jHneYCBhei9vgQ%40mail.gmail.com
>> <https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08QNMr1vG9nKd7TxoSHMHmFpG5bmFMh5jHneYCBhei9vgQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CA%2BLLie4YwXDJMibr0rSWU2R%2BpLUFKkcc6TQZP9SW8TuAjfjiGw%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CA%2BLLie4YwXDJMibr0rSWU2R%2BpLUFKkcc6TQZP9SW8TuAjfjiGw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Karl Auer

Email  : ka...@2pisoftware.com
Website: http://2pisoftware.com

GPG/PGP : 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816
Previous: F0AB 6C70 A49D 1927 6E05 81E7 AD95 268F 2AB6 40EA

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08RhXMXU63nxrkDwEXKEnVbvxL66AaybO3F%2BLt_zAnHttQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] with_sequence run a line only once

2019-01-05 Thread Karl Auer
Please provide sample code, or pseudocode

On Sun, Jan 6, 2019 at 12:08 AM Piyush Bansal 
wrote:

> Hello,
>
> I am trying to loop over a task using "with_sequence" and I need to make
> it work such that it run one specific line only once but rest of the lines
> it executes as normal times.
> It not succeeding or I am not able to figure out how to do it.
> Please advise
>
> Ansible 2.7.5
> Python: 3.6.6
> CentOS
> Target Host: HP3PAR storage
>
> Activity: I need to create 800 LUNs with different capacity
>
> Thanks,
> Piyush
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CA%2BLLie4kwRpuZ1HeAPtgaRUFj7G1N%3D4DyE2pXwj%2BtjoxbFGf4Q%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CA%2BLLie4kwRpuZ1HeAPtgaRUFj7G1N%3D4DyE2pXwj%2BtjoxbFGf4Q%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Karl Auer

Email  : ka...@2pisoftware.com
Website: http://2pisoftware.com

GPG/PGP : 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816
Previous: F0AB 6C70 A49D 1927 6E05 81E7 AD95 268F 2AB6 40EA

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08QNMr1vG9nKd7TxoSHMHmFpG5bmFMh5jHneYCBhei9vgQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] AnsibleUndefinedVariable: 'dict object' has no attribute

2019-01-03 Thread Karl Auer
Your version has double quotes around the second line. The known working
version does not. Could that be an issue?

Regards, K.

On Fri, Jan 4, 2019 at 10:20 AM Freddie Eisa  wrote:

> I just ran the same thing you ddi with the same issue I had.
>
> On Jan 3, 2019, at 4:06 PM, Hugo Gonzalez  wrote:
>
> Got to be something else. Are these linux hosts?
>
> I tried this and it works:
>
> playbook:
>
> ---
> - hosts: all
>
>   tasks:
> - template:
> src: template.j2
> dest: /tmp/knownhosts
>
> 
>
> template:
>
> {% for host in groups['all'] %}
> {{ hostvars[host]['ansible_facts']['ssh_host_key_ecdsa_public'] }}
> {% endfor %}
>
> --
>
> I suggest you run the setup module on your managed hosts and see the
> structure of the facts on your hosts then, and see if the host keys are
> there with that name.
>
>
> Hugo G.
>
>
> On 1/3/19 4:33 PM, Freddie Eisa wrote:
>
> This is what I’m running
>
> My role
> - name: Template Knownhosts
>   template: src=./ssh_key.j2 dest=/tmp/temp.conf
>
> My template
> {% for host in groups['all'] %}
>"{{ hostvars[host]['ansible_facts']['ssh_host_key_ecdsa_public'] }}"
> {% endfor %}
>
> My playbook
>
> ---
> - name: Centos 7 Servers
>   hosts: servers_all
>   gather_facts: True
>   ignore_errors: yes
>   roles:
>- linux-role
>
>
> --
> HUGO F. GONZALEZ
>
> SENIOR CONSULTANT
> Red Hat LATAM <https://www.redhat.com/>
> <https://red.ht/sig>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/51fe343a-0562-0849-9161-4a0d04366503%40redhat.com
> <https://groups.google.com/d/msgid/ansible-project/51fe343a-0562-0849-9161-4a0d04366503%40redhat.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/4B57DC00-7EAD-4209-97FA-C75F30038649%40gmail.com
> <https://groups.google.com/d/msgid/ansible-project/4B57DC00-7EAD-4209-97FA-C75F30038649%40gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
> --
> HUGO F. GONZALEZ
>
> SENIOR CONSULTANT
> Red Hat LATAM <https://www.redhat.com/>
> <https://red.ht/sig>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/8feca239-8c6b-4ef8-8331-4d26489f125c%40redhat.com
> <https://groups.google.com/d/msgid/ansible-project/8feca239-8c6b-4ef8-8331-4d26489f125c%40redhat.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/A7231E7C-CA93-44B8-BCCD-A0862C691B18%40gmail.com
> <https://groups.google.com/d/msgid/ansible-project/A7231E7C-CA93-44B8-BCCD-A0862C691B18%40gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Karl Auer

Email  : ka...@2pisoftware.com
Website: http://2pisoftware.com

GPG/PGP : 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816
Previous: F0AB 6C70 A49D 1927 6E05 81E7 AD95 268F 2AB6 40EA

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08RcnnB79%2BTjdZXZxh%2BTHYTbxy9WmdLBHuK5tsmq7dT0sQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] How to Random Roles

2019-01-03 Thread Karl Auer
Are you trying to randomly select a role, randomly select a host, then run
the selected role on the selected host?

On Fri, Jan 4, 2019 at 12:09 AM Francis Santos  wrote:

> I gotta random both the hosts and the roles.
> I successfully randomed the hosts, but I not getting the roles to random.
> Here is what I got
>
> ---
> - hosts: "{{ (groups['foo'] | shuffle)[0:1] }}"
>   become: yes
>   vars:
>- ansible_sudo_pass: **
>
> * roles:  *
> *   - reboot || shutdown*
>
> Need a way to random a single role among all roles. In this example I have
> a reboot and shutdown
>
> Any suggestions?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/6f35d604-d0bc-4b51-9e60-7d002064256a%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/6f35d604-d0bc-4b51-9e60-7d002064256a%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Karl Auer

Email  : ka...@2pisoftware.com
Website: http://2pisoftware.com

GPG/PGP : 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816
Previous: F0AB 6C70 A49D 1927 6E05 81E7 AD95 268F 2AB6 40EA

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08Sx2UA3xvJrmcnZLJN0-tX1-dLbNzLTALGHVwPoL4%3DB3w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] How to manage AWS resources by Ansible Without Access Keys and Secret Access Keys

2019-01-03 Thread Karl Auer
I have used the ec2 module a LOT on a build host with an instance policy
and have never had to include those two items. I simply omit them. The
module still works fine.

So I think you CAN "just skip them"... as long as you have an appropriate
instance policy. And (obviously) as long as Ansible is executing the module
on the system with the instance policy!

Regards, K.


On Thu, Jan 3, 2019 at 3:35 PM Dick Visser  wrote:

>
>
> On Wed, 2 Jan 2019 at 17:56, S Saravanan 
> wrote:
>
>> Thanks for your reply.
>>
>> I will create role with limited policy and check it.
>>
>> Even If we assign roles, how to write playbooks without access and secret
>> access keys , keys in variable file or export ACCESS_KEYS..etc.
>>
>> For below example, without keys variable, how ansible will communicate
>> AWS API ?
>>
>> - name: create ec2 instance
>>ec2:
>> aws_access_key: ""   <-  without this
>> line
>> aws_secret_key: "" <- without
>> this line
>> image: ami-abcdefghi
>> wait: yes
>> instance_type: t2.micro
>> group_id: security_group.group_id
>> region: us-east-2
>> count_tag:
>>  Name: webserver
>> exact_count: 1
>>register: ec2
>>
>
> Those two options are mandatory for the module to work, you cannot just
> skip them.
> AWS provides you with temporary credentials based that give access to the
> iam policy the machine is assigned.
> You should be able to retrieve those from the instance’s metadata:
>
>
> https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html#instance-metadata-security-credentials
>
> When you have set up some (initially restricted, as Karl said) policy, I
> suggest using the ec2_metadata_facts module to find the temporary
> credentials:
>
> https://docs.ansible.com/ansible/2.4/ec2_metadata_facts_module.html
>
> Then simply refer to the appropriate keys in your ec2 task.
>
> Dick
>
>
>
> Regards,
>> Saravanan S
>>
>> On Wednesday, January 2, 2019 at 5:10:21 PM UTC+5:30, Karl Auer wrote:
>>>
>>> It sounds as if you need to run ansible on an AWS instance, and create
>>> an instance policy for the instance. Read up on instance policies in the
>>> AWS doco.
>>>
>>> The simplest instance policy is just a role that gives the instance
>>> AdministratorAccess, but depending on what you are planning to use Ansible
>>> to do, that may be overkill. You should avoid giving an instance too much
>>> power, just as you should avoid giving a user too much power.
>>>
>>> The big advantage of using an instance policy is that software on the
>>> instance - like Ansible - can do anything the instance is allowed to do,
>>> without having to worry about IAM users, access keys or secrets of any kind
>>> (although you will need to be able to log into the instance to do stuff).
>>>
>>> The other thing you can do is attach a limited instance policy first,
>>> and change it later - any change to the role will be effective almost
>>> immediately.
>>>
>>> Regards, K.
>>>
>>> On Wed, Jan 2, 2019 at 10:13 PM S Saravanan 
>>> wrote:
>>>
>>>> Hi All,
>>>>
>>>> How can we manage AWS resources by Ansible without Access Keys and
>>>> Secret Access Keys ?
>>>> There is a requirement to use Ansible server to manage AWS, but should
>>>> not use access and secret keys for security policy in the project.
>>>> We have to use only IAM role based access for this.
>>>> Which IAM role can be used ? what are the policies need to attached
>>>> with the role ?
>>>>
>>>> Please give some suggestions.
>>>>
>>>> Thank you in advance.
>>>>
>>>> Regards,
>>>> Saravanan S
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Ansible Project" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to ansible-proje...@googlegroups.com.
>>>> To post to this group, send email to ansible...@googlegroups.com.
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/ansible-project/0791a097-c8bf-457a-8ab7-ed307df1fc70%40googlegroups.com
>>>> <https://groups.google.com/d/msgid/ansibl

Re: [ansible-project] How to manage AWS resources by Ansible Without Access Keys and Secret Access Keys

2019-01-02 Thread Karl Auer
If the tasks are being carried out on the Ansible server, then you just
leave out the access keys and so on. If the tasks are being carried out on
other hosts, then those hosts are the ones that will need AWS access,
either via an instance policy or via access keys etc. And Ansible will need
suitable credentials to access the hosts it is running the tasks on.

Regards, K.

On Thu, Jan 3, 2019 at 3:35 PM Dick Visser  wrote:

>
>
> On Wed, 2 Jan 2019 at 17:56, S Saravanan 
> wrote:
>
>> Thanks for your reply.
>>
>> I will create role with limited policy and check it.
>>
>> Even If we assign roles, how to write playbooks without access and secret
>> access keys , keys in variable file or export ACCESS_KEYS..etc.
>>
>> For below example, without keys variable, how ansible will communicate
>> AWS API ?
>>
>> - name: create ec2 instance
>>ec2:
>> aws_access_key: ""   <-  without this
>> line
>> aws_secret_key: "" <- without
>> this line
>> image: ami-abcdefghi
>> wait: yes
>> instance_type: t2.micro
>> group_id: security_group.group_id
>> region: us-east-2
>> count_tag:
>>  Name: webserver
>> exact_count: 1
>>register: ec2
>>
>
> Those two options are mandatory for the module to work, you cannot just
> skip them.
> AWS provides you with temporary credentials based that give access to the
> iam policy the machine is assigned.
> You should be able to retrieve those from the instance’s metadata:
>
>
> https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html#instance-metadata-security-credentials
>
> When you have set up some (initially restricted, as Karl said) policy, I
> suggest using the ec2_metadata_facts module to find the temporary
> credentials:
>
> https://docs.ansible.com/ansible/2.4/ec2_metadata_facts_module.html
>
> Then simply refer to the appropriate keys in your ec2 task.
>
> Dick
>
>
>
> Regards,
>> Saravanan S
>>
>> On Wednesday, January 2, 2019 at 5:10:21 PM UTC+5:30, Karl Auer wrote:
>>>
>>> It sounds as if you need to run ansible on an AWS instance, and create
>>> an instance policy for the instance. Read up on instance policies in the
>>> AWS doco.
>>>
>>> The simplest instance policy is just a role that gives the instance
>>> AdministratorAccess, but depending on what you are planning to use Ansible
>>> to do, that may be overkill. You should avoid giving an instance too much
>>> power, just as you should avoid giving a user too much power.
>>>
>>> The big advantage of using an instance policy is that software on the
>>> instance - like Ansible - can do anything the instance is allowed to do,
>>> without having to worry about IAM users, access keys or secrets of any kind
>>> (although you will need to be able to log into the instance to do stuff).
>>>
>>> The other thing you can do is attach a limited instance policy first,
>>> and change it later - any change to the role will be effective almost
>>> immediately.
>>>
>>> Regards, K.
>>>
>>> On Wed, Jan 2, 2019 at 10:13 PM S Saravanan 
>>> wrote:
>>>
>>>> Hi All,
>>>>
>>>> How can we manage AWS resources by Ansible without Access Keys and
>>>> Secret Access Keys ?
>>>> There is a requirement to use Ansible server to manage AWS, but should
>>>> not use access and secret keys for security policy in the project.
>>>> We have to use only IAM role based access for this.
>>>> Which IAM role can be used ? what are the policies need to attached
>>>> with the role ?
>>>>
>>>> Please give some suggestions.
>>>>
>>>> Thank you in advance.
>>>>
>>>> Regards,
>>>> Saravanan S
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Ansible Project" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to ansible-proje...@googlegroups.com.
>>>> To post to this group, send email to ansible...@googlegroups.com.
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/ansible-project/0791a097-c8bf-457a-8ab7-ed307df1fc70%40googlegroups.com
>>>> <https://groups.google.com/d/msgid/ansible-project/

Re: [ansible-project] How to manage AWS resources by Ansible Without Access Keys and Secret Access Keys

2019-01-02 Thread Karl Auer
It sounds as if you need to run ansible on an AWS instance, and create an
instance policy for the instance. Read up on instance policies in the AWS
doco.

The simplest instance policy is just a role that gives the instance
AdministratorAccess, but depending on what you are planning to use Ansible
to do, that may be overkill. You should avoid giving an instance too much
power, just as you should avoid giving a user too much power.

The big advantage of using an instance policy is that software on the
instance - like Ansible - can do anything the instance is allowed to do,
without having to worry about IAM users, access keys or secrets of any kind
(although you will need to be able to log into the instance to do stuff).

The other thing you can do is attach a limited instance policy first, and
change it later - any change to the role will be effective almost
immediately.

Regards, K.

On Wed, Jan 2, 2019 at 10:13 PM S Saravanan 
wrote:

> Hi All,
>
> How can we manage AWS resources by Ansible without Access Keys and Secret
> Access Keys ?
> There is a requirement to use Ansible server to manage AWS, but should not
> use access and secret keys for security policy in the project.
> We have to use only IAM role based access for this.
> Which IAM role can be used ? what are the policies need to attached with
> the role ?
>
> Please give some suggestions.
>
> Thank you in advance.
>
> Regards,
> Saravanan S
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/0791a097-c8bf-457a-8ab7-ed307df1fc70%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/0791a097-c8bf-457a-8ab7-ed307df1fc70%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Karl Auer

Email  : ka...@2pisoftware.com
Website: http://2pisoftware.com

GPG/PGP : 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816
Previous: F0AB 6C70 A49D 1927 6E05 81E7 AD95 268F 2AB6 40EA

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08S5Cgd8Xy%2BvhtsRykeXwE02NC2fKrGoqS%2BiWW696%2BymzA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Help passing list from Ansible to Terraform list variable

2018-12-23 Thread Karl Auer
I haven't used the terraform module. but have just had a look at the
Ansible doc for it, and it describes a "variables" parameter as "a group of
key-values to override template variables or those in variables files."
Seems that this format in ansible would work to pass that parameter:

- terraform:
  [...]
  variables:
  plain_var: "string value"
  list_var: [ "list_element1", "list_element_2" ]
  map_var:
  one_thing: "blah"
  otherthing: "bloo"
  [...]

Note that "variables" is the literal name of the attribute; it is literally
the word "variables".

However, I suspect that "plain_var", "list_var" etc need to be variable
names that Terraform expects to see, and the contents have to be forms that
Terraform expects.
I can see several ways this might not be working:

   - you have a syntax error in your Ansible code; this would cause an
   error message from Ansible, and Terraform would not be called at all.
   - you are not using the "variables" attribute, and are trying to pass
   the variable directly as an attribute to the terraform module. This
   would cause some kind of "unrecognised attribute" error in Ansible, and
   Terraform would not be called at all.
   - you are using the "variables" attribute, but passing a variable name
   in it that Terraform doesn't know about; this would cause some kind of
   error in Terraform
   - you are using the "variables" attribute and you are using a variable
   name known to Terraform, but the contents of the variable you are passing
   are in some way incomplete or defective. This would cause some kind of
   error in Terraform.

It would be helpful to see the actual code you are trying and the actual
errors produced when you do.

Regards, K.

On Mon, Dec 24, 2018 at 7:07 AM Stephen Nesbitt 
wrote:

> All:
>
> I am using the terraform module and have a terraform plan that contains a
> list type variable. (Ansible 2.7.2)
>
> It may be my lack of deep knowledge of YAML, but every attempt I've tried,
> results in a validation error.
>
> My suspicion is that terraform expects the list to be passed in a certain
> format. This is based on the terraform docs
> <https://www.terraform.io/docs/configuration/variables.html> which show
> that one can pass a list in as environment variable with the format:
>
> $ TF_VAR_somelist='["ami-abc123", "ami-bcd234"]' terraform plan
>
>
> But I have been utterly unable to figure out how to pass this format from
> Ansible (i.e. yaml) to Terraform.
>
> Does anyone know how I can get this to work without resorting to an
> environment variable.
>
> Thx,
>
> -steve
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/3944fde6-c611-41ff-8f95-aa21ecf461c0%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/3944fde6-c611-41ff-8f95-aa21ecf461c0%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Karl Auer

Email  : ka...@2pisoftware.com
Website: http://2pisoftware.com

GPG/PGP : 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816
Previous: F0AB 6C70 A49D 1927 6E05 81E7 AD95 268F 2AB6 40EA

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08RdCk1G-rbWVQMHYjKbiQQ8bPtf2YHUHYLR9tTxNrMBeg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


  1   2   3   >