The Playbook is perfect. But still I am getting errors. Any clue?

38 views
Skip to first unread message

Prabhakaran Karuppaih

unread,
Oct 1, 2020, 11:30:47 AM10/1/20
to Ansible Project
---
- hosts: starfish
  become: yes
  vars:
    current_mysql_root_password: ""
    updated_mysql_root_password: "Password"
    current_mysql_asterisk_password: ""
    updated_mysql_asterisk_password: "PasswordAsterisk"

  tasks:

  - name: Install epel-release
    dnf:
      name: epel-release
      state: present
      
  - name: Install dependencies
    dnf:
      name: ['vim', 'wget', 'MySQL-python']
      state: present

  - name: Install the MySQL repo.
    dnf:
      state: present

  - name: Install mysql-server
    dnf:
      name: mysql-server
      state: present

  - name: Override variables for MySQL (RedHat).
    set_fact:
      mysql_daemon: mysqld
      mysql_packages: ['mysql-server']
      mysql_log_error: /var/log/mysqld.err
      mysql_syslog_tag: mysqld
      mysql_pid_file: /var/run/mysqld/mysqld.pid
      mysql_socket: /var/lib/mysql/mysql.sock
    when: ansible_os_family == "RedHat"

  - name: Ensure MySQL server is running
    service:
      name: mysqld
      state: started
      enabled: yes
    
  - name: update mysql root pass for localhost root account from local servers
    mysql_user:
      login_user: root
      login_password: "{{ current_mysql_root_password }}"
      name: root
      host: "{{ item }}"
      password: "{{ updated_mysql_root_password }}"
    with_items:
        - localhost
        
  - name: update mysql root password for all other local root accounts
    mysql_user: 
      login_user: root
      login_password: "{{ updated_mysql_root_password }}"
      name: root
      host: "{{ item }}"
      password: "{{ updated_mysql_root_password }}"
    with_items:
      - "{{ inventory_hostname }}"
      - 127.0.0.1
      - ::1
      - localhost.localdomain

  - name: create asterisk database
    mysql_db:
      login_user: root
      login_password: "{{ updated_mysql_root_password }}"
      name: asterisk
      state: present

  - name: asterisk mysql user
    mysql_user:
      login_user: root
      login_password: "{{ updated_mysql_root_password }}"
      name: asterisk
      host: "{{ item }}"
      password: "{{ updated_mysql_asterisk_password }}"
      priv: "asterisk.*:ALL"
    with_items:
      - "{{ inventory_hostname }}"
      - 127.0.0.1
      - ::1
      - localhost
      - localhost.localdomain

  - name: remove anonymous user
    mysql_user:
      login_user: root
      login_password: "{{ updated_mysql_root_password }}"
      name: ""
      state: absent
      host: "{{ item }}"
    with_items:
      - localhost
      - "{{ inventory_hostname }}"
      - 127.0.0.1
      - ::1
      - localhost.localdomain

  - name: remove test database
    mysql_db:
      login_user: root
      login_password: "{{ updated_mysql_root_password }}"
      name: test
      state: absent

  - user:
      name: asterisk
      state: present
      createhome: yes

  - group:
      name: asterisk
      state: present

  - user:
      name: egorogl
      groups: asterisk,wheel
      state: present

  - name: Install other dependencies
    dnf:
      name:
      - unixODBC
      - unixODBC-devel
      - mysql-connector-odbc
      - MySQL-python
      - tcpdump
      - ntp
      - ntpdate
      - jansson
      - bind-utils
      state: present

  - firewalld:
      port: 5060/udp
      permanent: true
      state: enabled

  - firewalld:
      port: 10000-20000/udp
      permanent: true
      state: enabled

  - name: Ensure NTP is running
    service:
      name: ntpd
      state: started
      enabled: yes

  - name: update odbcinst.ini
    lineinfile:
      dest: /etc/odbcinst.ini
      regexp: "{{ item.regexp }}"
      line: "{{ item.line }}"
      state: present
    with_items:
      - regexp: "^Driver64"
        line: "Driver64 = /usr/lib64/libmyodbc8a.so"
      - regexp: "^Setup64"
        line: "Setup64 = /usr/lib64/libodbcmyS.so"

  - name: create odbc.ini
    blockinfile: 
      path: /etc/odbc.ini
      create: yes
      block: |
        [asterisk]
        Driver = MySQL
        Description = MySQL connection to 'asterisk' database
        Server = localhost
        Port = 3306
        Database = asterisk
        UserName = asterisk
        Password = {{ updated_mysql_asterisk_password }}
        Socket = /var/lib/mysql/mysql.sock
...

Dick Visser

unread,
Oct 1, 2020, 12:43:35 PM10/1/20
to ansible...@googlegroups.com
Please don't send pictures of screenshots, and certainly not through
such obfuscated URLs.
How can I know it's not some dodgy malware behind that URL?
So don't make it so difficult for everyone and just post the TEXT
content (copy paste).
This will also increase the chance of a useful answer.
> --
> 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 view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/33147171-729a-44e8-85e5-3f46575c3a22n%40googlegroups.com.



--
Dick Visser
Trust & Identity Service Operations Manager
GÉANT
Reply all
Reply to author
Forward
0 new messages