[ansible-project] Re: Unnerving include_role behaviour
For reference, I created and issue in GitHub for this at https://github.com/ansible/ansible/issues/39543 On Monday, 9 April 2018 22:42:36 UTC+1, Dave H wrote: > > Hi, > > I'm trying to get some clarity on the expected behaviour of the following > scenario. I've included the file contents of a demonstration set of roles > below. My question is about the behaviour of the include vs import changes > between 2.3.2.0 and 2.4+. On 2.3.2.0, the included > role would be executed as part of roles/first/tasks/main.yml. But in > 2.4+, the included role is never executed at all, seemingly because the > excluded second role (which has a dependency on first) is excluded. > > My expectation is the 2.3.2.0 behaviour where as first explicitly > included, the included will be executed at that point. > > Note: included isn't specified as a meta dependency of first as it is > required to run at a particular point in the execution of first. The > second role is skipped for conditional reasons but I don't want that to > affect the inclusion in the first role. It's a bit unnerving if a role > further down the playbook can have an impact on what a previous role in the > playbook actually executes. i.e. I could have a playbook that does > everything I want, then add a new conditional role to the playbook and > break the original functionality. > > Is this behaviour correct? Should I be changing the include_role in first > to be import_role or doing something different, or is there something not > right? > > Running on ubuntu 14.04 and 16.04 with python 2.7.11. > > Any advice would be greatly appreciated. > > Many thanks, > > Dave > > With ansible 2.3.2.0, the "debug message from included" is executed as > expected: > > PLAY [localhost] > *** > > > TASK [Gathering Facts] > * > ok: [localhost] > > > TASK [first : first debug from first] > ** > ok: [localhost] => { > "msg": "first debug from first" > } > > > TASK [included : debug message from included] > ** > ok: [localhost] => { > "msg": "debug message from included" > } > > > TASK [first : last debug from first] > *** > ok: [localhost] => { > "msg": "last debug from first" > } > > > TASK [included : debug message from included] > ** > skipping: [localhost] > > > TASK [second : Debug from second] > ** > skipping: [localhost] > > > PLAY RECAP > * > localhost : ok=4changed=0unreachable=0failed= > 0 > > > With ansible 2.5.0, the "debug message from included" is skipped: > > PLAY [localhost] > *** > > > TASK [Gathering Facts] > * > ok: [localhost] > > > TASK [first : first debug from first] > ** > ok: [localhost] => { > "msg": "first debug from first" > } > > > TASK [first : include_role] > > > > TASK [included : debug message from included] > ** > skipping: [localhos
[ansible-project] Re: HP ILO set from ansible (no OS installed)
It's a python library. Create a new virtualenv, activate it, install ansible and python-hpilo and you should be good to run your playbook virtualenv venv . venv/bin/activate pip install ansible python-hpilo ansible-playbook -i "localhost," -c local playbook.yml On Wednesday, 11 April 2018 10:10:11 UTC+1, Benny Kusman wrote: > > Hi Dave, > > So i got this stupid question, where is the library of to put this hpilo ? > i was looking at https://github.com/ansible/ansible/issues/7633, but > couldnt find the solution. > > Thank you > > On Tuesday, April 10, 2018 at 3:38:46 AM UTC, Dave H wrote: >> >> Hi Benny, >> >> There are a couple of development modules in the ansible docs, e.g. >> https://docs.ansible.com/ansible/devel/modules/hpilo_boot_module.html, >> but I have not used them. >> >> I use the python package from http://seveas.github.io/python-hpilo to >> expose a command line interface and use an example playbook like the >> following. You have to extract data from the output of the cli but it's >> fairly straightforward and very useful. >> >> ansible-playbook -i "localhost," -c local playbook.yml >> >> --- >> >> - hosts: localhost >> gather_facts: false >> >> vars: >> >> ilo_host: "192.168.0.10" # IP address / hostname of the iLO >> interface >> ilo_user: "x" # username for the user to log into the iLO >> ilo_password: "xx"# fetch from vault or other secret storage >> hpilo_cli_cmd: "hpilo_cli {{ ilo_host }} --json --login='{{ ilo_user >> }}' --password='{{ ilo_password }}'" >> >> tasks: >> >> - name: Get current power status >> command: "{{ hpilo_cli_cmd }} get_host_power_status" >> register: hpilo_cli_get_host_power_status >> >> - name: Record power status >> set_fact: >> power_status: "{% if 'ON' in >> hpilo_cli_get_host_power_status.stdout %}ON{% else %}OFF{% endif %}" >> >> - name: Power on server - if it is powered down >> command: "{{hpilo_cli_cmd}} press_pwr_btn" >> when: power_status != "ON" >> >> - name: Reboot server - if it is powered up >> command: "{{hpilo_cli_cmd}} cold_boot_server" >> when: power_status == "ON" >> >> Hope that helps. >> >> Dave >> >> >> On Monday, 9 April 2018 09:37:15 UTC+1, Benny Kusman wrote: >>> >>> Hi, >>> >>> has anyone implemented setting up HP ILO using ansible, when the server >>> has no OS yet ? >>> if the server has been installed and has hponcfg command, there is >>> ansible module for it. >>> >>> But wondering, if anyone has tried to setup the server in the ilo using >>> ansible (just simply specifying the ilo hostname, userid/password, port) >>> >>> 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/d843e73d-cca7-4896-b435-0998e84d372f%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[ansible-project] Re: HP ILO set from ansible (no OS installed)
Hi Benny, There are a couple of development modules in the ansible docs, e.g. https://docs.ansible.com/ansible/devel/modules/hpilo_boot_module.html, but I have not used them. I use the python package from http://seveas.github.io/python-hpilo to expose a command line interface and use an example playbook like the following. You have to extract data from the output of the cli but it's fairly straightforward and very useful. ansible-playbook -i "localhost," -c local playbook.yml --- - hosts: localhost gather_facts: false vars: ilo_host: "192.168.0.10" # IP address / hostname of the iLO interface ilo_user: "x" # username for the user to log into the iLO ilo_password: "xx"# fetch from vault or other secret storage hpilo_cli_cmd: "hpilo_cli {{ ilo_host }} --json --login='{{ ilo_user }}' --password='{{ ilo_password }}'" tasks: - name: Get current power status command: "{{ hpilo_cli_cmd }} get_host_power_status" register: hpilo_cli_get_host_power_status - name: Record power status set_fact: power_status: "{% if 'ON' in hpilo_cli_get_host_power_status.stdout %}ON{% else %}OFF{% endif %}" - name: Power on server - if it is powered down command: "{{hpilo_cli_cmd}} press_pwr_btn" when: power_status != "ON" - name: Reboot server - if it is powered up command: "{{hpilo_cli_cmd}} cold_boot_server" when: power_status == "ON" Hope that helps. Dave On Monday, 9 April 2018 09:37:15 UTC+1, Benny Kusman wrote: > > Hi, > > has anyone implemented setting up HP ILO using ansible, when the server > has no OS yet ? > if the server has been installed and has hponcfg command, there is ansible > module for it. > > But wondering, if anyone has tried to setup the server in the ilo using > ansible (just simply specifying the ilo hostname, userid/password, port) > > 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/575de21c-8c32-448a-9f6c-f0567d1157ba%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[ansible-project] Unnerving include_role behaviour
Hi, I'm trying to get some clarity on the expected behaviour of the following scenario. I've included the file contents of a demonstration set of roles below. My question is about the behaviour of the include vs import changes between 2.3.2.0 and 2.4+. On 2.3.2.0, the included role would be executed as part of roles/first/tasks/main.yml. But in 2.4+, the included role is never executed at all, seemingly because the excluded second role (which has a dependency on first) is excluded. My expectation is the 2.3.2.0 behaviour where as first explicitly included, the included will be executed at that point. Note: included isn't specified as a meta dependency of first as it is required to run at a particular point in the execution of first. The second role is skipped for conditional reasons but I don't want that to affect the inclusion in the first role. It's a bit unnerving if a role further down the playbook can have an impact on what a previous role in the playbook actually executes. i.e. I could have a playbook that does everything I want, then add a new conditional role to the playbook and break the original functionality. Is this behaviour correct? Should I be changing the include_role in first to be import_role or doing something different, or is there something not right? Running on ubuntu 14.04 and 16.04 with python 2.7.11. Any advice would be greatly appreciated. Many thanks, Dave With ansible 2.3.2.0, the "debug message from included" is executed as expected: PLAY [localhost] *** TASK [Gathering Facts] * ok: [localhost] TASK [first : first debug from first] ** ok: [localhost] => { "msg": "first debug from first" } TASK [included : debug message from included] ** ok: [localhost] => { "msg": "debug message from included" } TASK [first : last debug from first] *** ok: [localhost] => { "msg": "last debug from first" } TASK [included : debug message from included] ** skipping: [localhost] TASK [second : Debug from second] ** skipping: [localhost] PLAY RECAP * localhost : ok=4changed=0unreachable=0failed=0 With ansible 2.5.0, the "debug message from included" is skipped: PLAY [localhost] *** TASK [Gathering Facts] * ok: [localhost] TASK [first : first debug from first] ** ok: [localhost] => { "msg": "first debug from first" } TASK [first : include_role] TASK [included : debug message from included] ** skipping: [localhost] TASK [first : last debug from first] *** ok: [localhost] => { "msg": "last debug from first" } TASK [second : Debug from second] ** skipping: [localhost] PLAY RECAP * localhost : ok=3changed=0unreachable=0failed=0 To run the playbook: ansible-playbook -i "localhost," -c local playbook.yml playbook.yml --- - hosts: localhost roles: - { role: first } - { role: second, when: some_variable | default(false) } roles/first/tasks/main.yml --- - name: first debug from first debug: