Re: [ansible-project] Trying to copy script from local to remote and run

2018-10-16 Thread 'Chris Bidwell - NOAA Federal' via Ansible Project
So I simplified my playbook a bit.  I disabled selinux on both servers and
I'm still getting an error.

---
- name: Check for reboot
  hosts: baseserver-lx
  become: yes

  vars_files:
- passwd.yml
- vars.yml

  vars:
script_dir: "~/"
script: "~/needs-restarting.py"

  tasks:
- name: Copy script
  copy:
src: "{{ script }}"
dest: "{{ script }}"
owner: root
group: root
mode: 0700

- name: Check for reboot
  command: "{{ script }}"
  register: reboot_reqd
  ignore_errors: true
  changed_when: false

- name: "Rebooting {{ ansible_hostname }}"
  shell: sleep 1 && reboot
  async: 30
  poll: 1
  ignore_errors: true
  when:
- reboot_reqd.rc == 1

- name: Wait for ssh to come back available
  wait_for:
host: "{{
(ansible_ssh_host|default(ansible_host))|default(inventory_hostname) }}"
port: 22
search_regex: OpenSSH
delay: 10
timeout: 240
  vars:
ansible_connection: local
  when: reboot_reqd.rc == 1

ERROR:
TASK [Copy script]
***
An exception occurred during task execution. To see the full traceback, use
-vvv. The error was: If you are using a module and expect the file to exist
on the remote, see the remote_src option
fatal: [baseserver-lx]: FAILED! => {"changed": false, "msg": "Could not
find or access '~/needs-restarting.py' on the Ansible Controller.\nIf you
are using a module and expect the file to exist on the remote, see the
remote_src option"}


On Mon, Oct 15, 2018 at 10:45 AM Kai Stian Olstad <
ansible-project+l...@olstad.com> wrote:

> On Thursday, 11 October 2018 22.30.13 CEST 'Chris Bidwell - NOAA Federal'
> via Ansible Project wrote:
> > cat check_for_reboot.yml
> > ---
> > - name: Check for reboot
> >   hosts: testserver
> >   become: yes
> >
> >   vars_files:
> > - passwd.yml
> > - vars.yml
> >
> >   vars:
> > script_dir: "/home/tsg/scripts"
> >
> >   tasks:
> > - name: Does script directory exist?
> >   stat:
> > path: "{{ script_dir }}"
> >   register: dir_exists
>
> You don't need to do this, the file module will check if the directory
> exist and create if it doesn't exist.
>
>
> >
> > - name: Does script exist?
> >   stat:
> > path: "{{ script_dir }}/needs-restarting.py"
> >   register: fic
>
> You don't need to do this, the copy module will check if the file exist
> and create/copy if it doesn't exist.
>
>
> > - name: Create scripts dir
> >   file:
> > state: directory
> > path: "{{ script_dir }}"
> > owner: tsg
> > group: tsg
> > mode: 0755
> >   when: dir_exists.stat.exists == false
> >
> > - name: Copy script
> >   copy:
> > src: "{{ script_dir }}/needs-restarting.py"
> > dest: "{{ script_dir }}/needs-restarting.py"
> > owner: tsg
> > group: tsg
> > mode: 0755
> >   when: fic.stat.exists == false
> >
> > - name: Check for reboot
> >   command: "{{ script_dir }}/needs-restarting.py -r"
> >   register: reboot_reqd
> >   ignore_errors: true
> >   changed_when: false
> >
> > - name: "Rebooting {{ ansible_hostname }}"
> >   shell: sleep 1 && reboot
> >   async: 30
> >   poll: 1
> >   ignore_errors: true
> >   when: reboot_reqd.rc == 1
>
> If you are using Ansible 2.7 I recommend using the reboot module.
>
> https://docs.ansible.com/ansible/2.7/modules/reboot_module.html#reboot-module
>
> If not you should change it to this to avoid errors.
>
>   - name: "Rebooting {{ ansible_hostname }}"
> shell: sleep 2 && reboot
> async: 1
> poll: 0
> when: reboot_reqd.rc == 1
>
>
> > - name: Wait for ssh to come back available
> >   wait_for:
> > host: "{{
> > (ansible_ssh_host|default(ansible_host))|default(inventory_hostname) }}"
> > port: 22
> > search_regex: OpenSSH
> > delay: 10
> > timeout: 240
> >   vars:
> > ansible_connection: local
> >   when: reboot_reqd.rc == 1
>
> Instead of wait_for I highly recommend using wait_for_connection instead
> because that module will check the remote host is ready to execute Ansible
> modules before it continues.
> (With the reboot module this is not needed)
>
>
> > Output:
> > TASK [Create scripts dir]
> >
> *
> > changed: [testserver]
> >
> > TASK [Copy script]
> >
> 
> > An exception occurred during task execution. To see the full traceback,
> use
> > -vvv. The error was: If 

[ansible-project] Do YAML inventory plugins support inheritance?

2018-10-16 Thread Guy Knights
I'm experimenting with the new AWS_EC2 plugin and have been wondering if 
there's a way to streamline the file as we have separate inventory folders 
for dev, demo and prod. Is there a way to do something like and 'include' 
for the bulk of the YAML file content and just have the different 
environment filters in each inventory's specific file? eg. something like 
this:

Central file (central.aws_ec2.yml):
plugin: aws_ec2
regions:
  - us-east-1
  - us-east-1
  - us-west-1
  - us-west-2
  - ap-southeast-2
filters:
  instance-state-name: running
strict_permissions: False
hostnames:
  - tag:Name
  - private-ip-address
strict: False
keyed_groups:
  - prefix: ''
separator: ''
key: tags.Type

Demo inventory file (demo.aws_ec2.yml):
include: central.aws_ec2.yml
filters:
  tag:Environment: demo

Thanks,
Guy

-- 
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/3199f5c1-ce55-4a87-9492-af87246035d1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Help using two options for a value for a template

2018-10-16 Thread gabriel . eidlin
Hi guys,

Here is why im triying to do:

im generating passwords and registering the output in a variable like this

- name: Generate Server Password
  raw: Secret=$(az keyvault secret show --name AdminPassword 
--vault-name "{{ keyvault }}" --query value --output tsv);if [ -z $Secret 
];then echo $(?~' | head -c 32 );else 
echo "$Secret"  ;fi
  register: AdminPassword



after i have that AdminPassword variable inside a template of 
azure_rm_deployment


AdminPassword:
value: "{{ LogRWebAdminPassword.stdout_lines[0] }}"



If the passwords generates it works ok. but if the password doesnt generate 
(cos sometimes we dont want to generate) it fails cos its waiting a value. 
I tried to use the operator default like this but it doues not work


AdminPassword:
value: "{{ LogRWebAdminPassword.stdout_lines[0] | 
default(string) }}"



Anyone has some idea how can i give the AdminPassword value options if the 
1st one fails?

Thanks a lot!


-- 
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/1351e6d5-af9b-410e-9930-01e4459ef9c0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Help with optimization of 3 tasks (mainly pip and command)

2018-10-16 Thread 'Anatol' via Ansible Project
Hi,

I would need advice for following tasks:

*1)*

*What I want to do as shell command:*
gdal-config --version | cut -c 1-5 | xargs -I % pip install 
'pygdal>=%.0,<=%.999'

Is it possible to use above pipe´s return as version with pip module *or 
should I use just command module*?
- name: Install correct Version of pygdal
  pip: 
name: pygdal
version: 2.2.1.3 # this should be dynamic as above
virtualenv: "/home/ts/.venv/foo"


*2.)*
*Is there some nicer way of using django-admin with a virtualenv as using a 
command module like:*
- name: Create new Django project from template 
  command: "/home/ts/.venv/foo/bin/django-admin startproject 
--template=./some-project -e py,rst,json,yml,ini,env,sample -n Dockerfile 
my_foo"
  args:
chdir: "/home/ts/foo/"
creates: "/home/ts/foo/my_foo"


*3)*
*What I want to do as shell command:*
source /home/ts/.venv/foo/bin/activate
cd /home/ts/foo
pip install -e . --upgrade

Is this correctly translated?

- name: Upgrade pip packages 
  pip: 
name: "/home/ts/foo"
editable: true
virtualenv: "/home/ts/.venv/foo"
extra_args: --upgrade

Thanks.

– Toni

-- 
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/8e1e2f7f-375e-46cd-82d3-cabe060ef55d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Working with Ansible Galaxy Roles

2018-10-16 Thread Mischa ter Smitten
I can really recommend submodules, but it's probably a bit more advance 
than requirements.yml. We manage over 150 roles this way and it's working 
like a charm.


On Tuesday, October 16, 2018 at 6:37:21 PM UTC+2, Matt Davies wrote:
>
> Thanks for the prompt response Jonathan
>
> So the roles being separate git repos would then be git submodules?
>
> Is that the idea?
>
> I'll read up on requirements.yml now.
>
> Matt
>  
>

-- 
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/da5ec2fc-fb8c-471d-9bc2-7d4da0032c07%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Help with blockinfile module running against Proxmox

2018-10-16 Thread Arturo Martínez
Hello Troy,

Only joined this group to confirm that your solution works, and say *thank 
you so much*. I spent a whole weekend trying to find workarounds for this 
issue, until I found your comment.

All the best,

Arturo

On Saturday, March 10, 2018 at 11:03:20 PM UTC+1, Troy Cauble wrote:
>
> I found it.  /etc/pve is a non-posix compliant filesystem
> https://pve.proxmox.com/wiki/Proxmox_Cluster_File_System_(pmxcfs)
> and blockinfile (and many other file modules) do their work in /tmp and 
> end with the
> equivalent of "cp -a" or "cp -p" which fails to /etc/pve.
>
> Workaround is to copy: to /tmp, do blockinfile: there, "command: cp" back.
>
> -troy
>
>

-- 
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/3d79419b-b72a-4a82-baa7-1ac1cceac143%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Working with Ansible Galaxy Roles

2018-10-16 Thread Jonathan Lozada De La Matta
not exactly. Each role will be in its own git repository then
requirements.yml will list all the roles you need for that specific play.
Makes it easier to manage the roles in different git repositories and not
have other changes mixed together.

On Tue, Oct 16, 2018 at 12:37 PM Matt Davies  wrote:

> Thanks for the prompt response Jonathan
>
> So the roles being separate git repos would then be git submodules?
>
> Is that the idea?
>
> I'll read up on requirements.yml now.
>
> Matt
>
>
> --
> 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/2c41b238-c8c5-4ecc-97af-69da2b8363fa%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
-- 

Jonathan lozada de la matta

AUTOMATION PRACTICE

-- 
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/CAFYJA%2BKygyb-zXGvCzK_7AyDu_ZqvakDHc0%3DAf%3DWx9KCAwOCxw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Working with Ansible Galaxy Roles

2018-10-16 Thread ngonzal
You can also update ansible.cfg to point to one or more role directories.  
Which is nice if each of your roles is in a git repo, but you want to work 
on things locally without pushing up changes every time.  See the 
roles_path 
option: 
https://docs.ansible.com/ansible/latest/reference_appendices/config.html#default-roles-path

On Tuesday, October 16, 2018 at 11:37:21 AM UTC-5, Matt Davies wrote:
>
> Thanks for the prompt response Jonathan
>
> So the roles being separate git repos would then be git submodules?
>
> Is that the idea?
>
> I'll read up on requirements.yml now.
>
> Matt
>  
>

-- 
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/29a9c74e-c86a-4165-99ff-d8bb229c7ba0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Re: AWS_EC2 plugin keyed_groups suffix option

2018-10-16 Thread Guy Knights
Never mind, I worked out that if I include the region (but not the 
boto_profile parameter) then it works. Not sure why it's not using the 
profile region defined in ~/.aws/config but it's not a big deal.

On Monday, 15 October 2018 17:28:52 UTC-7, Guy Knights wrote:
>
> Great, thanks! That seems to have worked.
>
> One other question related to aws_ec2 - I usually pass the AWS_PROFILE var 
> on the command line when I call ansible, eg. "AWS_PROFILE=myawsprofile 
> ./ansible-playbook -i inventory/prod/ playbooks/site.yml". However, with my 
> aws_ec2 inventory file, if I leave out the boto_profile and regions 
> variables the inventory list returns nothing. I have to explicitly include 
> these two parameters with a specific profile name and region in order for 
> it to return a list of my instances. I tried setting boto_profile: 
> 'env:AWS_PROFILE' or just 'AWS_PROFILE' (in addition to just leaving it 
> out) but it doesn't work. What am I doing wrong?
>
> Thanks again,
> Guy
>
> On Mon, 15 Oct 2018 at 17:07, flowerysong  wrote:
>
>> On Monday, October 15, 2018 at 7:45:15 PM UTC-4, Guy Knights wrote:
>>>
>>> Is there any way to specify a suffix for the keyed_groups option in the 
>>> aws_ec2 inventory plugin? I'm looking at migrating from Ansible 2.4 to 2.6 
>>> and would like to switch from the old ec2 dynamic inventory script. 
>>> However, we currently specify our host groups as "_servers", 
>>> eg. "web_servers". Is there any way I can replicate this host group format 
>>> in the aws_ec2 plugin or am I out of luck?
>>>
>>> I know I could change the format of our host groups but I'd prefer not 
>>> to have to do that if possible as there are conditional includes, etc I'd 
>>> have to adjust as well.
>>>
>>
>> Sure, just include the suffix in the key.
>>
>> keyed_groups:
>>   - prefix: ''
>> separator: ''
>> key: tags.Class ~ '_servers'
>>
>>  
>> "all": {
>> "children": [
>> "aws_ec2", 
>> "builder_servers", 
>> "ctools_mx_servers", 
>> "dev_servers", 
>> "dnsbl_servers", 
>> "egress_servers", 
>> "jail_servers", 
>> "master_servers", 
>> "mx_servers", 
>> "relay_egress_servers", 
>> "syslog_servers", 
>> "ungrouped"
>> ]
>>
>> -- 
>> You received this message because you are subscribed to a topic in the 
>> Google Groups "Ansible Project" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/ansible-project/Zp2FtD1hiqQ/unsubscribe
>> .
>> To unsubscribe from this group and all its topics, 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/2bb67f08-245e-41df-95d2-de695b47914b%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> -- 
>  
> Guy Knights • Senior Systems Engineer
> c: 778-996-2687p: 778-379-5120
>   
>   
>   
>

-- 
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/17b2be1a-bf6a-4a06-875d-056c021a7cef%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] include_role with passed variable defined by template fails

2018-10-16 Thread Dmitriy Panteleyev
Sorry, that was just a typo in my example.  The filenames all match.



On Tuesday, October 16, 2018 at 8:48:22 AM UTC-6, Matt Martz wrote:
>
> The template does not exist.  You are using the wrong template file in 
> your lookup call:
>
> ```
> - stuff: "{{ lookup('template', 'role_one_template.j2') }}"
> ```
>
> However, you have indicated the file is actually 
> named: /roles/one/templates/role_one_template_file.j2
>
> On Mon, Oct 15, 2018 at 11:06 PM Dmitriy Panteleyev  > wrote:
>
>> I'm a bit confused how variables are defined when using `include_role`.  
>> A basic example follows.
>>
>> */play.yml*
>> - hosts: localhost
>>   roles:
>> - one
>>
>>
>>
>> */roles/one/tasks/main.yml*
>> ---
>> - name: do a thing with another role
>>   include_role:
>> name: two
>>   vars:
>>passed_variable:
>>  - stuff: "{{ lookup('template', 'role_one_template.j2') }}"
>>
>>
>> */roles/one/templates/role_one_template_file.j2*
>> bla bla bla bla 
>> random bit of stuff
>> does not matter what 
>>
>>
>> */roles/two/tasks/main.yml*
>> ---
>> - debug:
>> var: passed_variable
>>
>>
>> My expectation is that role "one" will pull the template and pass the 
>> *results* of that lookup to role "two".  However, when running the play, 
>> I get first a warning, and then an error.  It *seems* as if the template 
>> lookup occurs in role "two".  So, what exactly is going on, and how do I 
>> fix it?
>>
>>
>> looking for "role_one_template.j2" at 
>>> "/roles/two/templates/role_one_template.j2"
>>> looking for "role_one_template.j2" at "/roles/two/role_one_template.j2"
>>> looking for "role_one_template.j2" at "/templates/role_one_template.j2"
>>> looking for "role_one_template.j2" at "/role_one_template.j2"
>>>  [WARNING]: Unable to find 'role_one_template.j2' in expected paths (use 
>>> -v to see paths)
>>
>> ...
>>> ...
>>
>> ERROR! An unhandled exception occurred while templating '{u'stuff': [{{ 
>>> lookup(\'template\', \'role_one_template.j2\') }}]}'.
>>> Error was a , original message: An 
>>> unhandled exception occurred while running the lookup plugin 'template'.
>>> Error was a , original message: the 
>>> template file role_one_template.j2 could not be found for the lookup
>>
>>
>>
>>
>> -- 
>> 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/16d95836-e93b-4e98-828d-9b4f176a0047%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> -- 
> Matt Martz
> @sivel
> sivel.net
>

-- 
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/caff13ff-e78a-4fd2-ba50-d48e2f7a79cc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Working with Ansible Galaxy Roles

2018-10-16 Thread Matt Davies
Thanks for the prompt response Jonathan

So the roles being separate git repos would then be git submodules?

Is that the idea?

I'll read up on requirements.yml now.

Matt
 

-- 
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/2c41b238-c8c5-4ecc-97af-69da2b8363fa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Working with Ansible Galaxy Roles

2018-10-16 Thread Jonathan Lozada De La Matta
checkout requirements.yml and having each role in a seperate git repo.

On Tue, Oct 16, 2018 at 12:26 PM Matt Davies  wrote:

> Hi Everyone
>
> There's about 10 developers working on our ansible codebase, configuring
> approx 20 VM's, it's going to grow rapidly.
>
> We've just started working with ansible galaxy roles and I was wondering
> if anyone has any links/tips/suggestions on how to manage the workflow?
>
> We'd like to be able to update the ansible galaxy roles easily.
>
> Are we talking about using git submodules here? I've read a bit about a
> requirements file?
>
> Any tips or help will be greatly appreciated.
>
> Thanks in advance
>
> Matt
>
> --
> 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/97794648-0778-4f8d-a232-3afbf1fecb58%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
-- 

Jonathan lozada de la matta

AUTOMATION PRACTICE

-- 
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/CAFYJA%2BLuV_1VOEXqsdxQcqoYeQ56hsVw6Ztqvv7uoPAz1OOn0A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Working with Ansible Galaxy Roles

2018-10-16 Thread Matt Davies
Hi Everyone

There's about 10 developers working on our ansible codebase, configuring 
approx 20 VM's, it's going to grow rapidly.

We've just started working with ansible galaxy roles and I was wondering if 
anyone has any links/tips/suggestions on how to manage the workflow?

We'd like to be able to update the ansible galaxy roles easily.

Are we talking about using git submodules here? I've read a bit about a 
requirements file?

Any tips or help will be greatly appreciated.

Thanks in advance

Matt

-- 
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/97794648-0778-4f8d-a232-3afbf1fecb58%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Problem: regex should find the end of the line - take the next new line

2018-10-16 Thread Kai Stian Olstad

On 16.10.2018 12:34, Shlomit Afgin wrote:

Hi,
I have

  - name: update file1 with 0 in the end if it missing
replace:
  backup: yes
  dest: /tmp/file1
  regexp: '^(start of line.*[^0])$'
  replace: '\1 0'


This add 0 to lines that start with "start of line".

It's run okay if there are no empty lines between.
If there is empty line under the match line it add the 0 to the empty 
line.

For example, the 2 lines:
start of line fjhdsjkfhdsk


will be:
start of line fjhdsjkfhdsk
0

instead of:
start of line fjhdsjkfhdsk 0


I tried to add the (?

It's in the documentation of the module under regexp.


--
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/eda784e67bc540eec163d36bb0f5d5c7%40olstad.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] include_role with passed variable defined by template fails

2018-10-16 Thread Matt Martz
The template does not exist.  You are using the wrong template file in your
lookup call:

```
- stuff: "{{ lookup('template', 'role_one_template.j2') }}"
```

However, you have indicated the file is actually
named: /roles/one/templates/role_one_template_file.j2

On Mon, Oct 15, 2018 at 11:06 PM Dmitriy Panteleyev 
wrote:

> I'm a bit confused how variables are defined when using `include_role`.  A
> basic example follows.
>
> */play.yml*
> - hosts: localhost
>   roles:
> - one
>
>
>
> */roles/one/tasks/main.yml*
> ---
> - name: do a thing with another role
>   include_role:
> name: two
>   vars:
>passed_variable:
>  - stuff: "{{ lookup('template', 'role_one_template.j2') }}"
>
>
> */roles/one/templates/role_one_template_file.j2*
> bla bla bla bla
> random bit of stuff
> does not matter what
>
>
> */roles/two/tasks/main.yml*
> ---
> - debug:
> var: passed_variable
>
>
> My expectation is that role "one" will pull the template and pass the
> *results* of that lookup to role "two".  However, when running the play,
> I get first a warning, and then an error.  It *seems* as if the template
> lookup occurs in role "two".  So, what exactly is going on, and how do I
> fix it?
>
>
> looking for "role_one_template.j2" at
>> "/roles/two/templates/role_one_template.j2"
>> looking for "role_one_template.j2" at "/roles/two/role_one_template.j2"
>> looking for "role_one_template.j2" at "/templates/role_one_template.j2"
>> looking for "role_one_template.j2" at "/role_one_template.j2"
>>  [WARNING]: Unable to find 'role_one_template.j2' in expected paths (use
>> -v to see paths)
>
> ...
>> ...
>
> ERROR! An unhandled exception occurred while templating '{u'stuff': [{{
>> lookup(\'template\', \'role_one_template.j2\') }}]}'.
>> Error was a , original message: An
>> unhandled exception occurred while running the lookup plugin 'template'.
>> Error was a , original message: the
>> template file role_one_template.j2 could not be found for the lookup
>
>
>
>
> --
> 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/16d95836-e93b-4e98-828d-9b4f176a0047%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Matt Martz
@sivel
sivel.net

-- 
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/CAD8N0v9sN3B%2BXcmjM5XWmqFDBJH79f8E22Pe5zKj2XXZ6SheSg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] template error: AnsibleUndefinedVariable

2018-10-16 Thread christian . tremel
hi,

i have a simple template which is driving me nuts, as it throws an bland 
error. what in blazes does that mean?

the template:

{{ ansible_managed }}

driftfile /etc/ntp.drift
tracefile /etc/ntp.trace

{% if inventory_lparname not in groups['DMZ_HOST'] %}
server 10.0.0.1
server some_host
{% elif inventory_lparname in groups['DMZ_HOST'] %}
server 10.0.0.2
{% endif %}


error:

MSG:

AnsibleUndefinedVariable: Unable to look up a name or access an attribute in 
template string ({{ ansible_managed }}

driftfile /etc/ntp.drift
tracefile /etc/ntp.trace

{% if inventory_lparname not in groups['DMZ_HOST'] %}
server 10.0.0.1
server some_host
{% elif inventory_lparname in groups['DMZ_HOST'] %}
server 10.0.0.2
{% endif %}
).
Make sure your variable name does not contain invalid characters like '-': 
argument of type 'StrictUndefined' is not iterable



-- 
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/63015f79-26d2-4074-bceb-fe21fa5ab5da%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: shut unused cisco switch interfaces

2018-10-16 Thread Brad Van Orden
I don't currently have any switches to test against, but I would think you 
can get the interface status with ios_facts with the ansible_net_interfaces 
giving you a hash of the interface status.  From that, you should be able 
to use ios_interface to mark it down.  ansible check of IOS interfaces 
 gives a 
similar example.

On Monday, October 15, 2018 at 1:51:11 PM UTC-4, Ahmed Aljawad wrote:
>
> Is there is any way i can loop on all the devices interfaces and shut all 
> the Down Down ports ? 
>

-- 
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/ca094c59-3e9b-49b5-9ba5-3b2141a8b0f0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Problem: regex should find the end of the line - take the next new line

2018-10-16 Thread Shlomit Afgin

Hi,
I have 

  - name: update file1 with 0 in the end if it missing
replace:
  backup: yes
  dest: /tmp/file1
  regexp: '^(start of line.*[^0])$'
  replace: '\1 0'


This add 0 to lines that start with "start of line". 

It's run okay if there are no empty lines between.  
If there is empty line under the match line it add the 0 to the empty line. 
For example, the 2 lines: 
start of line fjhdsjkfhdsk  


will be:
start of line fjhdsjkfhdsk
0

instead of:
start of line fjhdsjkfhdsk 0


I tried to add the (?https://groups.google.com/d/msgid/ansible-project/99718063-6f71-41f6-b579-acb2e6fc81cb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Is there free gui interface or easy way to check Ansible's log

2018-10-16 Thread Jonathan Lozada De La Matta
ansible ARA might be what you are looking for.

On Tue, Oct 16, 2018 at 2:44 AM Julian Kriel 
wrote:

> Indeed,
>
> Look into AWX - Its Ansible tower open source project.
>
> Great management platform
>
> On Tue, Oct 16, 2018 at 8:20 AM Shlomit Afgin 
> wrote:
>
>> Hi,
>>
>> I'm in a middle of building Ansible on our system.
>> I would like to run it every day to check few servers.
>> Is there any good way to follow the Ansible's logs to check failed? Is
>> there any free GUI I can use with Ansible?
>> The Ansible's run give output and I want to get also only the
>> problematic/failed run in separate.
>>
>> Thank a lot.
>>
>> --
>> 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/7d308f7b-1eaa-4736-9282-585004f69789%40googlegroups.com
>> 
>> .
>> 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/CAJn-AMxKsBQYsM5KTjPKTkvSgEHRP-Udo0buRWk%3D6KekLcyEyA%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
-- 

Jonathan lozada de la matta

AUTOMATION PRACTICE

-- 
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/CAFYJA%2BLXUoES4euhOj_CK4M8ayapHfdXiySOYJkZMUREfSbH3g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Unable to change regional settings on Windows Server

2018-10-16 Thread ameya agashe
Hi Guys,

I want to change regional settings post-Windows Server Provisioning, 
namely "*Display language*" and "*Input Language*" for a) *Current User*, 
b) *Welcome Screen*, and c) *New user *to *"English Australia"*

[image: Regional-Settings.jpg]


I have the below module, unfortunately, it does not changes them to English 
- Australia, it keeps the default value to the* English United States* may 
I know what additional things do I need to add?


- name: install features on new Azure Windows Server
  hosts: all
  gather_facts: yes
  tasks:
  - name: Set timezone to 'A.U.S. Eastern Standard Time' (GMT+10:00)
win_timezone:
  timezone: E. Australia Standard Time
  - name: Set the region format to English Australia and copy settings to 
new profiles
win_region:
  location: 12
  format: en-AU
  copy_settings: True
  unicode_language: en-AU
register: result
  - win_reboot:
when: result.restart_required



Kindly assist.

Thank you very much.

Regards,
Ameya Agashe

-- 
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/0199a54f-bf27-4b00-bc2b-eae037401a68%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Is there free gui interface or easy way to check Ansible's log

2018-10-16 Thread Julian Kriel
Indeed,

Look into AWX - Its Ansible tower open source project.

Great management platform

On Tue, Oct 16, 2018 at 8:20 AM Shlomit Afgin  wrote:

> Hi,
>
> I'm in a middle of building Ansible on our system.
> I would like to run it every day to check few servers.
> Is there any good way to follow the Ansible's logs to check failed? Is
> there any free GUI I can use with Ansible?
> The Ansible's run give output and I want to get also only the
> problematic/failed run in separate.
>
> Thank a lot.
>
> --
> 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/7d308f7b-1eaa-4736-9282-585004f69789%40googlegroups.com
> 
> .
> 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/CAJn-AMxKsBQYsM5KTjPKTkvSgEHRP-Udo0buRWk%3D6KekLcyEyA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Is there free gui interface or easy way to check Ansible's log

2018-10-16 Thread Shlomit Afgin
Hi,

I'm in a middle of building Ansible on our system. 
I would like to run it every day to check few servers. 
Is there any good way to follow the Ansible's logs to check failed? Is 
there any free GUI I can use with Ansible?  
The Ansible's run give output and I want to get also only the 
problematic/failed run in separate.

Thank a lot.

-- 
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/7d308f7b-1eaa-4736-9282-585004f69789%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.