How can I execute one code block from local/master/control node?

23 views
Skip to first unread message

bente...@gmail.com

unread,
May 25, 2022, 1:03:54 AM5/25/22
to Ansible Project

I would like to execute the below tasks which create a user on a remote host and trigger an SMS gateway call from master/control node.

This is running from awx/(tower) where I get some of the parameters through an AWX survey.

---------------------------------------------

  - name: create users
    user:
            name={{ user_name }}
            comment={{ user_comment }}
            shell=/bin/bash
            home=/home/{{ user_name }}
            state=present
            createhome=yes
            password={{ my_pass | password_hash('sha512') }}
            update_password=on_create
    register: user_created

  - name: Expire password
    shell: chage -d 0 {{ user_name }}
    when: user_created.changed

  - name: Sent SMS to user
    uri:
            url: "http://example.com/bms/soap/Messenger.asmx/HTTP_SendSms?\
                  customerID={{ customerID }}&\
                  userName={{ userName }}&\
                  userPassword={{ userPassword }}&\
                  originator={{ originator }}&\
                  smsText=Hostname:%20{{ ansible_hostname }}%0aIP%20Address:%20{{ ansible_ssh_host }}%0ausername:%20{{ user_name }}%0aPassword:%20{{ my_pass }}%0a%0aNOTE:User%20needs%20to%20change%20password%20upon%20first%20login&\
                  recipientPhone={{ phone_number }}&\
                  messageType=Latin&\
                  blink=false&\
                  flash=false&\
                  Private=false&\
                  defDate=20220518090503"
    when: user_created.changed

-------------------------------------------------------

i gone through deligate_to, i tried adding that my code, still didn't worked.


can anyone please help me to achieve this? 


Thanks

bente...@gmail.com

unread,
May 26, 2022, 7:16:56 AM5/26/22
to Ansible Project
hello,

can anyone help me to achieve this?

Reply all
Reply to author
Forward
0 new messages