diff --git a/tasks/configure.yml b/tasks/configure.yml index df43464..270d11d 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -8,6 +8,7 @@ mode: 0644 with_items: "{{ postgresql_global_config_options }}" notify: restart postgresql + become: true - name: Configure host based authentication (if entries are configured). template: @@ -18,6 +19,7 @@ mode: 0600 notify: restart postgresql when: postgresql_hba_entries | length > 0 + become: true - name: Ensure PostgreSQL unix socket dirs exist. file: @@ -27,3 +29,4 @@ group: "{{ postgresql_group }}" mode: "{{ postgresql_unix_socket_directories_mode }}" with_items: "{{ postgresql_unix_socket_directories }}" + become: true diff --git a/tasks/initialize.yml b/tasks/initialize.yml index 8636a40..97618b5 100644 --- a/tasks/initialize.yml +++ b/tasks/initialize.yml @@ -5,6 +5,7 @@ dest: /etc/profile.d/postgres.sh mode: 0644 notify: restart postgresql + become: true - name: Ensure PostgreSQL data directory exists. file: @@ -13,11 +14,13 @@ group: "{{ postgresql_group }}" state: directory mode: 0700 + become: true - name: Check if PostgreSQL database is initialized. stat: path: "{{ postgresql_data_dir }}/PG_VERSION" register: pgdata_dir_version + become: true - name: Ensure PostgreSQL database is initialized. command: "{{ postgresql_bin_path }}/initdb -D {{ postgresql_data_dir }}" @@ -35,3 +38,4 @@ group: "{{ postgresql_group }}" state: directory mode: 0700 + become: true diff --git a/tasks/main.yml b/tasks/main.yml index ef53122..4d483a9 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -20,6 +20,7 @@ name: "{{ postgresql_daemon }}" state: "{{ postgresql_service_state }}" enabled: "{{ postgresql_service_enabled }}" + become: true # Configure PostgreSQL. - import_tasks: users.yml diff --git a/tasks/setup-RedHat.yml b/tasks/setup-RedHat.yml index d536bcb..724794c 100644 --- a/tasks/setup-RedHat.yml +++ b/tasks/setup-RedHat.yml @@ -8,9 +8,11 @@ # to be installed, which breaks later Ansible runs on Fedora 30, # and affects system behavior in multiple ways. exclude: python-unversioned-command + become: true - name: Ensure PostgreSQL Python libraries are installed. yum: name: "{{ postgresql_python_library }}" state: present enablerepo: "{{ postgresql_enablerepo | default(omit, true) }}" + become: true